Registry / database / mysql-promisify

mysql-promisify

JSON →
library1.0.2jsnpmunverified

A promisified wrapper around the popular mysql npm package, providing an async/await interface for MySQL queries, transactions, and connection pooling. Current stable version is 1.0.2, released in late 2020 with low maintenance cadence. Key differentiators: uses custom escape format with ':word' for values and '|word' for identifiers, stateless MySQL class with both pool and connection approaches, built-in transaction support via getTransactionDb(). Lightweight alternative to more heavyweight ORMs like Sequelize.

npm install mysql-promisify
INSTALL
IMPORT
SIG · MYSQL-PROMISIFY
M
mysql-promisify
databasejavascriptv1.0.2
harness data pending
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.

MySQL
✓ const { MySQL } = require('mysql-promisify');
✗ import { MySQL } from 'mysql-promisify';
Package does not expose ESM exports; CommonJS required
MySQL
✓ const MySQL = require('mysql-promisify').MySQL;
✗ const { MySQL } = require('mysql-promisify');
Both destructured and direct property access work
MySQL.queryFormat
✓ const query = MySQL.queryFormat(sql, params);
✗ const query = db.queryFormat(sql, params);
Static method on class, not on instance

Creates a MySQL instance and runs a query with named parameter binding using :param syntax.

const { MySQL } = require('mysql-promisify'); const db = new MySQL({ host: '127.0.0.1', user: 'root', password: process.env.DB_PASSWORD ?? '', database: 'test', }); async function main() { const { results } = await db.query({ sql: 'SELECT * FROM test WHERE id = :id', params: { id: 1 } }); console.log(results); } main().catch(console.error);
Debug
Known issues
gotchaCustom format uses ':word' for values and '|word' for identifiers, not the standard '?' or ':param'
fix
Use ':paramName' for values and '|paramName' for identifiers in SQL strings
affects: >=1.0.0
breakingTransaction connection released after commit/rollback; instance becomes unusable
fix
Obtain a new transaction handle via db.getTransactionDb() for each transaction
affects: >=1.0.0
deprecatedPackage last updated September 2020; no active development
fix
Consider migrating to mysql2/promise for official promise support
affects: >=1.0.0
gotchaImplicit commit may occur with certain SQL statements (DDL) inside transactions
fix
Avoid DDL statements inside transactions; refer to MySQL implicit commit documentation
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'mysql-promisify'
Package not installed or missing from node_modules
fix
npm install mysql-promisify --save
TypeError: db.query is not a function
Instance not created correctly or wrong import
fix
Ensure using 'const { MySQL } = require('mysql-promisify'); const db = new MySQL({...});'
Error: Connection lost: The server closed the connection.
MySQL server timeout or idle connection
fix
Set 'timeout' option in MySQL constructor or implement reconnection logic
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies
mysqlrequiredCore dependency providing MySQL driver functionality
Agent activity
4 hits · last 30 days
node
4
Resources
mysql-promisify — npm install mysql-promisify · libregistry