Skip to main content

Data PII cleaning/masking for databases

Project description

pgdatacleaner

Purpose

Mask sensetive data in a database (i.e. PII/PHI) so it can be used for development/testing purposes. It is meant to keep IDs, so databases that for some reason has PII data in PK/FKs won't work very well.

Usage

First, create a data dictionary from an existing database:

datadict 'postgresql://<user>:<password>@<host>/<database>' <schema> my_pii_dd.csv

You will need to edit this file and set pii to yes for any columns that need to be masked, and the pii_type to one of the available types to generate fake data. dataclean -h will list all available fakers.

Then, run dataclean to modify a database masking data as specified in the CSV. This is not a very fast operation on databases of any significant size.

dataclean -f 'postgresql://<user>:<password>@<host>/<database>' -f my_edited_pii_dd.csv

If you change your schema, adding/modifying/deleting columns and tables, you can regenerate the data dictionary using your last copy as a seed so you don't have to re-specify columns that have not changed:

datadict 'postgresql://<user>:<password>@<host>/<database>' <schema> -i my_existing_dd.csv my_new_pii_dd.csv

Status

Stable, supports postgresql and sqlite3. Consists of 45% todo's and hacks - still works.

Release history

* 1.1.4
  * Added static_str
  * Handle lists and dicsts as JSONB [] when writing back rows

Caveats

I'm not responsible for your data. Never run this against a production database, unless you feel like testing your backup restore procedures.

License

Copyright (c) 2021, Fredrik Håård

Do whatever you want, don't blame me. You may also use this software as licensed under the MIT or BSD licenses, or the more permissive license below:

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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

datamask-2.0.0.tar.gz (226.0 kB view details)

Uploaded Source

Built Distribution

datamask-2.0.0-py3-none-any.whl (290.6 kB view details)

Uploaded Python 3

File details

Details for the file datamask-2.0.0.tar.gz.

File metadata

  • Download URL: datamask-2.0.0.tar.gz
  • Upload date:
  • Size: 226.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.9.13 Linux/5.15.90.1-microsoft-standard-WSL2

File hashes

Hashes for datamask-2.0.0.tar.gz
Algorithm Hash digest
SHA256 a55ed48fa842558528de4019117507e46d80d00ed8d4c8f716a4ef0eaebec84c
MD5 8c3f4acc06c12db07598a05a1f17ce32
BLAKE2b-256 1afa238ef0d0e15448281929352726efb4849baef40281762b2c8aa9d17c339e

See more details on using hashes here.

File details

Details for the file datamask-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: datamask-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 290.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.9.13 Linux/5.15.90.1-microsoft-standard-WSL2

File hashes

Hashes for datamask-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 70cd30cb9ecfd1d504fe57faae97e98801a4a180ab4d6257e965e568060892f2
MD5 8be843ab515b908bc7075fe2ea9d7368
BLAKE2b-256 583aa8a74c837893bc87f981ab81f2c1cde6cae24f3f221cce4125bfd54d419a

See more details on using hashes here.

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