Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Database anonymizer package

Project description


PGAnonymizer is a tool for anonymizing database for testing purposes.


PGAnonymizer required Python 3.5 and above to run. PGAnonymizer can be installed using pip.

$ pip install pganonymizer


PGAnonymizer will hash columns in table depending on the rules inside CSJ file.

CSJ file format:

"table", "column", "rule"
"schema.table_to_be_hased", "columned_to_be_hased", "hash"
"schema.table_to_be_hased", "columned_to_be_hased", "date"
"schema.table_to_be_hased", "columned_to_be_hased", "phone"

Example for rules for hashing

Hash is for text type field such as name or address. The return value will be in base32 with length of atmost 16.
Example input:


Example output:


Date is for date type field. The return value will keep the original year but hash the month and date field.
Example input:


Example output:


Phone is for phone number. The return value will be of same length as the original number.
Example input:


Example output:




$ pganonymizer [database environment] [option]

To use PGAnonymizer, you can call:

$ pganonymizer --schema path_to_schema_file.csj

By default, PGAnonymizer will connect to database using user's username as database and role.
Otherwise, please specify as follow:

$ pganonymizer -d postgres -U postgres --schema path_to_schema_file.csj

For more information on the usage, please use the following command:

$ pganonymizer --help

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pganonymizer, version 0.0.5
Filename, size File type Python version Upload date Hashes
Filename, size pganonymizer-0.0.5-py3-none-any.whl (7.3 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size pganonymizer-0.0.5.tar.gz (4.8 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page