tengits-dbm
raw JSON → 1.0.12 verified Sat Apr 25 auth: no javascript
tengits-dbm (Database Manager CLI) is a command-line tool for MySQL connection management, migration, and data comparison. Current version is 1.0.12, released with moderate cadence, no changelog available. Key features: SSH tunnel support, AES-256-GCM encrypted password storage, connection pooling, schema/data comparison with multiple modes, and cross-server migration. Requires Node.js >=18.0.0, ships TypeScript types. Primarily aimed at developers and DevOps needing a scriptable, secure MySQL CLI with migration capabilities, differentiating by built-in SSH tunneling and encrypted credential storage.
Common errors
error ERR_REQUIRE_ESM: require() of ES Module /path/to/tengits-dbm/index.js not supported ↓
cause Using CommonJS require() on an ESM-only package.
fix
Change to ESM import: import { DBM } from 'tengits-dbm'; or set type: module in package.json.
error Error: Master password not set. Set DBM_MASTER_PASSWORD environment variable. ↓
cause Missing environment variable DBM_MASTER_PASSWORD before calling encryption-related functions.
fix
Set process.env.DBM_MASTER_PASSWORD = 'your-pass'; before using dbm.
error TypeError: dbm.addConnection is not a function ↓
cause Using wrong import or not initializing DBM instance properly.
fix
Use import { DBM } from 'tengits-dbm'; then const dbm = new DBM(); and call dbm.addConnection(...).
Warnings
gotcha Master password must be set via environment variable DBM_MASTER_PASSWORD before any operation; otherwise encryption/decryption fails silently or throws. ↓
fix export DBM_MASTER_PASSWORD='your-master-password' or set process.env.DBM_MASTER_PASSWORD in code before importing dbm.
deprecated CommonJS require is not supported; package is type: module. Using require will throw ERR_REQUIRE_ESM. ↓
fix Use ESM import syntax: import { DBM } from 'tengits-dbm'
gotcha SSH password authentication may expose credentials in process list (e.g., via ps aux). Use SSH key authentication whenever possible. ↓
fix Prefer --ssh-key-file over --ssh-password for SSH connections.
breaking Connection pool timeout default is 5 minutes; long-running queries may cause pool exhaustion if connections are not released properly. ↓
fix Use the ConnectionPoolManager to configure shorter timeout or increase max connections.
gotcha Database migration using --force overwrites target without confirmation; accidental data loss possible. ↓
fix Always backup target database before forced migration; use --backup flag.
Install
npm install tengits-dbm yarn add tengits-dbm pnpm add tengits-dbm Imports
- DBM CLI wrong
const dbm = require('tengits-dbm'); const DBM = require('tengits-dbm').DBM;correctimport { DBM } from 'tengits-dbm' - ConnectionPoolManager wrong
const ConnectionPoolManager = require('tengits-dbm').ConnectionPoolManager;correctimport { ConnectionPoolManager } from 'tengits-dbm' - encryptPassword wrong
const encryptPassword = require('tengits-dbm').encryptPassword;correctimport { encryptPassword } from 'tengits-dbm' - decryptPassword wrong
const decryptPassword = require('tengits-dbm').decryptPassword;correctimport { decryptPassword } from 'tengits-dbm'
Quickstart
// Set master password (required for encrypted storage)
process.env.DBM_MASTER_PASSWORD = 'your-secure-master-password';
import { DBM } from 'tengits-dbm';
const dbm = new DBM();
// Add a direct connection
await dbm.addConnection('mydb', {
host: '192.168.1.100',
port: 3306,
user: 'root',
password: 'mypassword'
});
// List all connections
const connections = await dbm.listConnections();
console.log(connections);
// Test connection
const testResult = await dbm.testConnection('mydb');
console.log(testResult ? 'Connection OK' : 'Connection failed');
// List databases
const databases = await dbm.listDatabases('mydb');
console.log(databases);
// Execute SQL
const result = await dbm.executeSQL('mydb', {
database: 'mydatabase',
sql: 'SELECT * FROM users LIMIT 10'
});
console.log(result);
// Remove connection
await dbm.removeConnection('mydb');