Skip to main content

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

Project description

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.

Project details


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)

Uploaded Source

Built Distribution

redacty-2.0.1-py3-none-any.whl (5.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page