Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

pg-anon

cactuslab18Apache-2.01.0.2TypeScript support: included

CLI to anonymize PostgreSQL data using Faker.js or Falso

postgres, faker.js, falso, anonymize, anonymization

readme

pg-anon

CLI to anonymize PostgreSQL data using Faker.js or Falso.

A configuration file-driven tool to iterate over the rows in tables in a PostgreSQL database, replacing specified columns with random / anonymized values generated by Faker, Falso or any a custom function (so basically any tool).

It runs in batches—by default of 100 rows—and commits after each batch. You can disable batching by setting the batch size to 0 in the config.

The seed capabilities of Faker and Falso are used so that the generated values are stable for each row and column.

Config

See pg-anon.config.js for an example config file. pg-anon looks for this file in your current working directory.

See types.ts for the type-definition of the config file, and documentation of the properties.

Here's a very basic example to whet your appetite:

/**
 * @type {import('pg-anon').PgAnonConfig}
 */
const config = {
    connectionString: 'postgres://user:password@host:port/database',
    tables: [
        {
            name: 'table1',
            idColumn: 'id',
            columns: {
                name: {
                    faker: 'person.fullName',
                },
            }
        },
    ],
}

export default config

Usage

To run pg-anon using a pg-anon.config.js in your current working directory:

npx pg-anon

Or to specify the path to the config file:

npx pg-anon <path to config file>