Skip to content

isabella232/node-db-info

 
 

Repository files navigation

db-info

db-info is a utility module which provides a database independent way of getting database metadata.

Build status Travis

The following databases are currently supported:

Quick Examples

var dbinfo = require("db-info");

dbinfo.getInfo({
  driver: 'mysql',
  user: 'root',
  password: 'root',
  database: 'test'
}, function(err, result) {
  /* result = {
    tables: {
      person: {
        name: 'person',
        columns: {
          'id': { name: 'id', notNull: true, primaryKey: true, type: 'integer', length: '11' },
          'name': { name: 'name', notNull: true, type: 'varchar', length: '255' },
          'email': { name: 'email', notNull: false, type: 'varchar', length: '100' },
          'age': { name: 'age', notNull: false, type: 'integer', length: '11' }
        }
      }
    }
  } */
});

Download

You can install using Node Package Manager (npm):

npm install db-info

Supported features

database columns+keys foreign keys
Oracle
MSSQL
Postgres
MySQL
SQLite -

Documentation

Command Line

db-info --driver=pg --connectionString=tcp://test:test@localhost/test

getInfo(opts, callback)

Gets the metadata from a database.

Arguments

  • opts - A hash of options.
  • driver - can be either "mysql", "sqlite3", "db-oracle", or "pg" (PostgreSQL)
  • db - if db is passed in this connection will be used instead of making a new connection.
  • other - will be passed to the drivers connect.
  • callback(err, result) - Callback called once complete. result will contain a hash containing all the tables along with column information.

Example

var db = new sqlite3.Database(':memory:');

dbinfo.getInfo({
  driver: 'sqlite3',
  db: db
}, function(err, result) {
});

About

No description, website, or topics provided.

Resources

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 99.0%
  • Other 1.0%