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

dbqp

v0.0.2

Published

A sync tool for MySQL database schema

Downloads

9

Readme

dbqp

A sync tool for MySQL database schema

Description

dbqp may help you dump database schema, diff (even sychronise directly) schemas of two databases.

Name dbqp is made up of abbreviation word db and its reflection qp.

dbqp

Declarations and Attentions

  • The author will be NOT responsible for any damage caused by dbqp on your database or data. Please do backup before using dbqp.
  • Until now, ONLY MySQL is supported.
  • Until now, ONLY TABLES are manipulated.
  • Until now, NO DROP opertaion is supported.

ToC

Get Started

dbqp offers both API and CLI.

CLI Mode

When installed globally, dbqp generates a homonymic command help you to manage database schema in command line.

# Install globally.
npm install -g dbqp

# Dump schema of database "employees".
dbqp dump --host localhost --user root --password root --database employees

Run dbqp help for entire manual.

API Mode

Of course, you can require dbqp into your Node.js program.

const dbqp = require('dbqp');

let conn = new dbqp.Connection({
    host: 'localhost',
    port: 3306,
    user: 'root',
    password: 'root',
});

conn.dump('employees', (err, metaJson) => {
    // ...
});

conn.diff('employeesCopy', 'employees', (err, SQLs) => {
    // ...
});

Standalone API Mode

Sub module of dbqp may be required as standalone module for specified task.

const dump = require('dbqp/mysql/dump');

const conn = {
    host: 'localhost',
    port: 3306,
    user: 'root',
    password: 'root',
};
dump(conn, 'employees', (err, metaJson) => {
    // ...
});

API

dbqp.Connection

const Connection = require('dbqp').Connection;
  • class dbqp.Connection( Object connOptions )
  • Promise <conn>.dump( string dbName )
  • Promise <conn>.diff( string refererDbName, string refereeDbName )
  • Promise <conn>.sync( string refererDbName, string refereeDbName )
  • void <conn>.dump( string dbName, Function callback )
  • void <conn>.diff( string refererDbName, string refereeDbName, Function callback )
  • void <conn>.sync( string refererDbName, string refereeDbName, Function callback )
  • void <conn>.destroy()

See also API Parameters.

dbqp/mysql/dump

const dump = require('dbqp/mysql/dump');
  • Promise <conn>.dump( Object connOptions, string dbName )
  • void <conn>.dump( Object connOptions, string dbName, Function callback )

See also API Parameters, dbqp Dump for MySQL.

dbqp/mysql/diff

const diff = require('dbqp/mysql/diff');
  • Promise <conn>.diff( Object connOptions, string refererDbName, string refereeDbName )
  • void <conn>.diff( Object connOptions, string refererDbName, string refereeDbName, Function callback )

See also API Parameters, dbqp Diff for MySQL.

dbqp/mysql/sync

const sync = require('dbqp/mysql/sync');
  • Promise <conn>.sync( Object connOptions, string refererDbName, string refereeDbName )
  • void <conn>.sync( Object connOptions, string refererDbName, string refereeDbName, Function callback )

See also API Parameters.

API Parameters

  • connOptions Object
    Contains necessary parameters required to connect to a MySQL server.

    {
        host, /* string DEFAULT 'localhost' */
        port, /* number DEFAULT 3306 */
        user, /* string */
        password, /* string */
    }
  • callback Function(Error, any)

Examples

Release Database Design

Suppose that you are in charge of maintaining an application which depending on a database.

In first edition v1.0, a SQL file 1.0.sql offered to initialize the database.

In second edition v2.0, something changed in database. A new SQL file 2.0.sql offered to initialize the database. However, to help early users of v1.0 to upgrade their existing databases, another upgrade-from-1.0.sql is necessary.

In third edition v3.0, more changes happened. You have to offer following SQL files:

  • 3.0.sql for new users.
  • uprade-from-2.0.sql for early users of v2.0.
  • uprade-from-1.0.sql for early users of v1.0.

When more and more editions released, it is really difficult to maintain more and more SQL files.

---- It can be easy with dbqp. ----

  • If you are developer, use dbqp dump to create schema.json which will be delivered to your users.
  • If you are user, whatever a new user or early user, use dbqp sync to make your database ready. Of course, you should create an empty database if it not exists.