redacty

This is a CLI tool that redacts emails from bodies of text in a PostgreSQL database.


License
MIT
Install
pip install redacty==2.0.1

Documentation

redacty

Release Build status Supported Python versions codecov Commit activity License

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.

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.