This is a CLI tool and Python API that redacts emails from bodies of text in a PostgreSQL database, with optional flags for an excluded domain and an older than x days filter.
- Github repository: https://github.com/wet-bulb/redacty/
Install redacty
with pip
pip install redacty
redacty <database_url> <table> <column> [-a AGE] [-x EXCLUDE]
- database_url: PostgreSQL database URL.
- table: Name of the table that holds the column to redact.
- column: Name of the column that holds the text to redact.
Optional arguments:
- -a AGE, --age AGE: Minimum age of records to be anonymized in days. Default is 0 days old.
- -x EXCLUDE, --exclude EXCLUDE: Email domain to exclude from anonymization.
Here's an example:
from redacty import anonymize_records
# Connect to the PostgreSQL database
conn = psycopg2.connect(database_url)
# Anonymize email addresses in the specified table and column, set minimum age, and no excluded domains
anonymize_records(conn, table, column, 30, " ")
# Close the database connection
conn.close()
Repository initiated with fpgmaas/cookiecutter-poetry.