https://github.com/joeferner/node-db-info
https://github.com/joeferner/node-db-info
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/joeferner/node-db-info
- Owner: joeferner
- Created: 2011-12-11T19:22:05.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2012-04-02T15:41:36.000Z (about 14 years ago)
- Last Synced: 2025-08-28T20:05:01.106Z (10 months ago)
- Language: JavaScript
- Homepage:
- Size: 156 KB
- Stars: 7
- Watchers: 6
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# db-info
db-info is a utility module which provides a database independent way of
getting database metadata.
The following databases are currently supported:
* sqlite3 - via: [node-sqlite3](https://github.com/developmentseed/node-sqlite3)
* mysql - via: [node-mysql](https://github.com/felixge/node-mysql)
* PostgreSQL - via: [node-postgres](https://github.com/brianc/node-postgres)
* Oracle - via: [node-oracle](https://github.com/mariano/node-db-oracle)
## 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 async
## Documentation
### Command Line
db-info --driver=pg --connectionString=--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) {
});