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 🙏

© 2025 – Pkg Stats / Ryan Hefner

dbinfoz

v0.14.0

Published

Get Database Info and Table Schemas

Readme

🌐 DBINFOZ Universal Database Adapter

A simple and unified interface to interact with different types of SQL databases including PostgreSQL, MySQL, MSSQL, and SQLite.

✨ Features

  • 📚 List all databases
  • 📃 List all tables within a database
  • 📄 Get the schema of a table
  • 🗂 Get all tables and their schemas within a database

Supports PostgreSQL, MySQL, MSSQL, and SQLite databases.

🛠 Installation

npm install dbinfoz

🚀 Usage

First, require the package and use the factory function to get an instance of the database adapter based on the type of database you're working with:

const getDatabaseAdapter = require('dbinfo');

// For PostgreSQL
const postgresConfig = {
  user: 'yourUsername',
  host: 'localhost',
  database: 'yourDatabase',
  password: 'yourPassword',
  port: 5432,
};
const postgresAdapter = getDatabaseAdapter('postgres', postgresConfig);

// For MySQL
const mysqlConfig = {
  host: 'localhost',
  user: 'yourUsername',
  database: 'yourDatabase',
  password: 'yourPassword',
  port: 3306,
};
const mysqlAdapter = getDatabaseAdapter('mysql', mysqlConfig);

// For MSSQL
const mssqlConfig = {
  host: 'localhost',
  user: 'yourUsername',
  database: 'yourDatabase',
  password: 'yourPassword',
  port: 3306,
};
const mssqlAdapter = getDatabaseAdapter('mssql', mssqlConfig);

// For SQLite
const sqliteConfig = {
  filename: './path/to/database.sqlite',
};
const sqliteAdapter = getDatabaseAdapter('sqlite', sqliteConfig);

📖 Examples

const getDatabaseAdapter = require('./index');

// Configuration for the required database
const config = {
  host: 'localhost', // For MySQL and PostgreSQL
  user: 'root', // For MySQL
  password: 'password', // For MySQL and PostgreSQL
  database: 'mydb',
  filename: './mydb.sqlite' // For SQLite
};

// Specify the database type ('sqlite', 'mysql', 'postgres')
const type = 'sqlite'; // Change as needed

(async () => {
  try {
    const dbAdapter = getDatabaseAdapter(type, config);

    // List databases
    const databases = await dbAdapter.listDatabases();
    console.log('Databases:', databases);

    // List tables
    const tables = await dbAdapter.listTables();
    console.log('Tables:', tables);

    // Get table schema
    const schema = await dbAdapter.getTableSchema('my_table');
    console.log('Schema:', schema);

    // Run a custom query
    const result = await dbAdapter.runQuery('SELECT * FROM my_table');
    console.log('Query Result:', result);

    // Close the connection (SQLite specific method for example purposes)
    if (dbAdapter.close) {
      await dbAdapter.close();
    }
  } catch (error) {
    console.error('Error:', error.message);
  }
})();

💡 Contributing

Contributions, issues, and feature requests are welcome! Feel free to check issues page.

📝 License

MIT © Jason Jacobs

📁 Repository

The source code is available at GitHub.