This is a CLI tool that redacts emails from bodies of text in a PostgreSQL database.
Project description
redacty
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/
Installation
Install redacty
with pip
pip install redacty
Usage/Examples
Command-Line Interface (CLI)
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.
Programatic Use in Python
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
redacty-2.0.1.tar.gz
(4.5 kB
view hashes)