Relational Database Metadata Utility

0.0.3 · abandoned · verified Wed Apr 22

The `db-info` package is a Node.js utility designed to provide a database-agnostic interface for retrieving relational database metadata, such as table and column schemas. It supports SQLite3, MySQL, PostgreSQL, and Oracle databases by leveraging older versions of `node-sqlite3`, `node-mysql`, `node-postgres`, and `node-oracle` drivers. The current and only known version is 0.0.3, last published in April 2012. Given its age and lack of updates for over a decade, this package is definitively abandoned and not actively maintained. Its API is entirely callback-based, reflecting Node.js development patterns from its release era. Key differentiators at the time were its unified interface across multiple database types for schema introspection, but it is now highly outdated compared to modern ORMs or database toolkit solutions.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to initialize `db-info` with an existing SQLite database connection to retrieve its table and column metadata.

const sqlite3 = require('sqlite3').verbose();
const dbinfo = require('db-info');

// Create an in-memory SQLite database for demonstration
const db = new sqlite3.Database(':memory:', (err) => {
  if (err) {
    return console.error(err.message);
  }
  console.log('Connected to the in-memory SQLite database.');

  // Create a dummy table
  db.run(`CREATE TABLE users (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    name TEXT NOT NULL,
    email TEXT UNIQUE,
    age INTEGER
  )`, (err) => {
    if (err) {
      // Table might already exist if run multiple times in same process
      if (err.message.includes('already exists')) {
        console.log('Table "users" already exists, proceeding.');
      } else {
        return console.error('Error creating table:', err.message);
      }
    } else {
      console.log('Table "users" created successfully.');
    }

    // Get database metadata using db-info
    dbinfo.getInfo({
      driver: 'sqlite3',
      db: db
    }, function(err, result) {
      if (err) {
        return console.error('Error getting DB info:', err.message);
      }
      console.log('Database metadata retrieved:');
      console.log(JSON.stringify(result, null, 2));

      // Close the database connection
      db.close((err) => {
        if (err) {
          return console.error(err.message);
        }
        console.log('Closed the database connection.');
      });
    });
  });
});

view raw JSON →