1.1.4 • Published 8 years ago

mysqldesc v1.1.4

Weekly downloads
16
License
MIT
Repository
github
Last release
8 years ago

mysqldesc

Build Status Code Climate Code Coverage npm Version

Describe mysql database. Get table names, column specs as a json object.

Installation

npm install mysqldesc --save-dev

Usage

Describe database data.

var mysqldesc = require('mysqldesc');

// Mysql connect config.
var config = {
    user: 'root',
    password: 'my_password',
    host: 'localhost',
    database: 'my_db'
};
// Desc connected database
mysqldesc(config, function (err, data) {
    console.log("structure=" + JSON.stringify(data, null, 4));
});

This will result like:

structure = { // Tables in "my_db" database.
    "TEST_PERSON": { // Columns in "TEST_PERSON" table.
        "PersonID": { // Spec of "TEST_PERSON.PersonID" column.
            "Type": "int(11)",
            "Null": "YES",
            "Key": "",
            "Default": null,
            "Extra": ""
        },
        "LastName": {
            "Type": "varchar(255)",
            "Null": "YES",
            "Key": "",
            "Default": null,
            "Extra": ""
        }
    },
    "TEST_SHOP": {
        /*...*/
    }
};

API

SignatureDescription
mysqldesc(config, callback)Describe tables in the connected database.
mysqldesc(config, databaseName, callback)Describe tables in a specific database.
mysqldesc(config, databaseName, tableName, callback)Describe a specific table.
mysqldesc.keyColumnUsage(config, callback)Describe key column usage in the connected database.
mysqldesc.keyColumnUsage(config, databaseName, callback)Describe key column usage in a specific database.
mysqldesc.keyColumnUsage(config, databaseName, tableName, callback)Describe key column usage in a specific table.

Tips

Connection Options

mysqldesc uses node-mysql as connector. For more advanced setting, see the node-mysql documents about Connection options

License

This software is released under the MIT License.

Links

1.1.4

8 years ago

1.1.3

10 years ago

1.1.2

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.8

10 years ago

1.0.7

10 years ago

1.0.6

10 years ago

1.0.5

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago