npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

anonymizer-mysql

v1.2.0

Published

This simple tool will allow you to make anonymized clone of your database.

Downloads

15

Readme

anonymizer-mysql

This simple tool will allow you to make anonymizerd clone of your database.

Installation

Yarn

yarn global add "anonymizer-mysql"

Npm

npm install --global "anonymizer-mysql"

Usage

You need to create a config(.json) file like this:

{
  "source_db": {
    "host": "localhost",
    "user": "user",
    "password": "password",
    "database": "source",
    "port": "3306"
  },
  "target_db": {
    "host": "localhost",
    "user": "user",
    "password": "password",
    "database": "target",
    "port": "3306"
  },
  "rules": [
    {
      "table": "users",
      "fields": [
        {
          "field": "username",
          "apply": "substring(md5(username),1,8)"
        },
        {
          "field": "password",
          "apply": "'da248eeaffa573da8c323c3eb56aaf32ec6ce244e401a24c55f30c907d0bbfb5'"
        },
        {
          "field": "surname",
          "apply": "substring(md5(surname),1,8)"
        },
        {
          "field": "name",
          "apply": "substring(md5(name),1,8)"
        },
        {
          "field": "email",
          "apply": "concat(substring(md5(email),1,8), '@email.com')"
        },
        {
          "field": "birthDate",
          "apply": "birthDate - INTERVAL FLOOR(RAND() * 30) DAY"
        },
        {
          "field": "photo",
          "apply": "'http://placehold.it/50x50'"
        }
      ],
      "where": "rolId = 5"
    },
    {
      "table": "users",
      "fields": [
        {
          "field": "password",
          "apply": "'da248eeaffa573da8c323c3eb56aaf32ec6ce244e401a24c55f30c907d0bbfb5'"
        },
        {
          "field": "surname",
          "apply": "substring(md5(surname),1,8)"
        },
        {
          "field": "name",
          "apply": "substring(md5(name),1,8)"
        }
      ],
      "where": "rolId = 1"
    },
    {
      "table": "users",
      "insertIgnore": true,
      "fields": [
        {
          "field": "username",
          "apply": "'johndoe'"
        },
        {
          "field": "surname",
          "apply": "'Doe'"
        },
        {
          "field": "password",
          "apply": "'3452343452AFF'"
        },
        {
          "field": "name",
          "apply": "'John'"
        }
      ]
    }
  ]
}

You need to configure the database connections. "source_db" referred to the original database to anonymize. "target_db" referred to the anonymized clone of the "source_db". Be care, in this process, the "target_db" database is going to be destroyed.

You need to configure rules to apply to a field of one table.

The "apply" JSON attribute indicates the MySQL function to execute, here your anonymizer function for this field. For example, use "substring(md5(name),1,8)" for anonymize the field called name.

For conditional queries use the JSON attribute "where".

You can create many conditional queries for the same table. See the example.

You can use "insertIgnore" as attribute and set it true if you want do a "INSERT IGNORE' instead of "UPDATE" query,

Once you has been created a config(.json) file, you can use this tool with: Usage: anonymizer-mysql [options]

Options:

-V, --version       output the version number
-f, --force         Overwrite the clone db if it already exists.
-c, --conf <file>   Config file. Default: config.json
-d, --dump <file>   Path to mysqldump. Default: system mysqldump.
-8, --dumpv8        If you use MySQL v8.x dump. (--column-statistics=0)
-m, --mysql <file>  Path to mysql. Default: system mysql.
-h, --help          output usage information