Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
default
✓ const MySqlDO = require('tmap-mysql');
✗ import MySqlDO from 'tmap-mysql';
Package is CommonJS only; no ESM export or TypeScript types.
MySqlDO
✓ const repo = new (require('tmap-mysql'))(connectionString);
✗ const repo = new MySqlDO();
Constructor requires a connection string argument; no default.
executeQuery
✓ const { executeQuery } = require('tmap-mysql');
✗ const executeQuery = require('tmap-mysql').executeQuery;
executeQuery is a method on the instance, not a static export. The correct import is the default class.
connectionString
✓ const repo = new MySqlDO('mysql://user:pass@host:3306/db');
✗ const repo = new MySqlDO({ host: 'localhost' });
Expects a single string, not an object. Use MySQL connection URL format.
Shows creating a repository with connection string, executing parameterized query, getting table data, inserting a row, checking pool status, and closing pool.
const MySqlDO = require('tmap-mysql');
const config = require('./config');
const dataRepo = new MySqlDO(config.mysqlConString);
async function main() {
try {
const users = await dataRepo.executeQuery('SELECT * FROM users WHERE id = ?', [1]);
console.log('User:', users);
const allUsers = await dataRepo.getTableData('users');
console.log('All users:', allUsers);
const newUser = await dataRepo.InsertRowFromData('users', { name: 'John', email: 'john@example.com' });
console.log('Inserted:', newUser);
const poolStatus = dataRepo.getPoolStatus();
console.log('Pool:', poolStatus);
} finally {
await dataRepo.closePool();
}
}
main().catch(console.error);
Errors
Common errors & fixes
TypeError: MySqlDO is not a constructor
Using wrong import style (e.g., import instead of require) or forgetting 'new'.
fixconst MySqlDO = require('tmap-mysql'); const repo = new MySqlDO(connectionString); Error: Cannot find module 'tmap-mysql'
Package not installed or not linked.
fixRun 'npm install tmap-mysql' or 'npm link tmap-mysql' in your project.
Error: getaddrinfo ENOTFOUND
Connection string host is incorrect or database server is not reachable.
fixVerify the MySQL host, port, and network connectivity. Use correct format: mysql://user:pass@host:3306/db.
Error: ER_ACCESS_DENIED_ERROR: Access denied for user
Invalid username or password in connection string.
fixCheck credentials in connection string. Ensure user has proper privileges.
Audit
Dependencies
mysql2requiredUnderlying MySQL driver for all database operations