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

mysqlminidump

v2.0.8

Published

Dumps your main table and all the required tables with foreign key constraints.

Downloads

19

Readme

! NEEDS mysqldump utility installed to work

mysqlminidump

Create small mysql dumps from your production database.

Dumps your main table and all the required tables with foreign key constraints.
Create fake foreign key constraints if you need.

install

npm install -g mysqlminidump
can be used with any version of node. Tested with 4.2.6 and 0.12.7

usage

mysqlminidump ~/config.json

config.json sample:

{
  "verbose": true,
  "chunkSize": 1000,
  "resultFile": "dump.sql",
  "mysqlConfig": {
    "host"     : "localhost",
    "user"     : "root",
    "password" : "password",
    "database" : "database"
  },
  "dumpConfig": {
    "table"       : "product",
    "primaryKey"  : "id",
    "starterQuery": "select * from product limit 100;"
  },
  "mysqldumpOptions": [],
  "overridePrimaryKey": {
    "category": "id"
  },
  "fakeConstraints": [{
    "TABLE_NAME"             : "product",
    "COLUMN_NAME"            : "merchant_id",
    "REFERENCED_TABLE_NAME"  : "merchant",
    "REFERENCED_COLUMN_NAME" : "id"
  }]
}

verbose

show logs

chunkSize

many dumps are created which are appended to the same file, this option tells how many ids to use to create a dump.

resultFile

output dump file path

mysqlConfig

mysql configuration

dumpConfig

  • table: name of the main table
  • primaryKey: primary key of main table
  • starterQuery: the query to start the dump process

mysqldumpOptions

array of mysqldump options

overridePrimaryKey

I have assumed primary key of all tables is id, to override use

--
"overridePrimaryKey": {
  tableName1: primaryKey1,
  tableName2: primaryKey2
}
--

fakeContraints

array of objects to inject fake foreign key constraints


Example

--
"dump": {
    "table"      : "product",
    "primaryKey" : "id",
    "offset"     : 0,
    "limit"      : 2
  },
--

FOREIGN KEY (category_id) REFERENCES category (id)
FOREIGN KEY (merchant_id) REFERENCES merchant (id)
brand_id is not a foreign key so we add an object in fakeConstraints

--
"fakeConstraints": [{
   "TABLE_NAME"             : "product",
   "COLUMN_NAME"            : "brand_id",
   "REFERENCED_TABLE_NAME"  : "brand",
   "REFERENCED_COLUMN_NAME" : "id"
 }]
--
  1. product

    | id | category_id | merchant_id | brand_id | |----|-------------|-------------|----------| | 1 | 5000 | 100 | 901 | | 2 | 5000 | 101 | 902 | | 3 | 5002 | 102 | 903 | | .. | .. | .. | .. |

  2. category

    | id | name | |------|-----------| | 5000 | category0 | | 5001 | category1 | | 5003 | category3 | | .. | .. |

  3. merchant

    | id | name | |-----|-----------| | 100 | merchant0 | | 101 | merchant1 | | 102 | merchant2 | | .. | .. |

  4. brand

    | id | name | |-----|-----------| | 901 | brand1 | | 902 | brand2 | | 903 | brand3 | | .. | .. |

resulting dump ids:

  1. product : [1,2]
  2. category : [5000]
  3. merchant : [100, 101]
  4. brand : [901, 902]