Registry / database / mysql-query-promise

mysql-query-promise

JSON →
library1.0.1jsnpmunverified

Lightweight promise-based wrapper around mysql-query-js for Node.js MySQL connections. Version 1.0.1, stable but unmaintained since 2015. Provides a single query() function that returns promises, with support for multiple named database configurations via the 'config' module. Differentiators: minimal API, integrated config management, and pool support. Alternatives: mysql2/promise, knex, or sequelize offer more features.

npm install mysql-query-promise
INSTALL
IMPORT
SIG · MYSQL-QUERY-PROMIS
M
mysql-query-promise
databasejavascriptv1.0.1
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.

query
const query = require('mysql-query-promise');
import query from 'mysql-query-promise';
Package uses CommonJS and does not provide ESM exports. Use require() only.
query as default import
const query = require('mysql-query-promise');
const { query } = require('mysql-query-promise');
The default export is a single function, not an object with named exports.
TypeScript usage
// @ts-ignore const query = require('mysql-query-promise');
import query from 'mysql-query-promise';
No TypeScript definitions available. Use require and disable type checking.

Promisified MySQL query execution with config-based connection pool.

const query = require('mysql-query-promise'); const qs = 'SELECT * FROM users WHERE id = ?'; query(qs, [1], 'master') .then(rows => console.log(rows)) .catch(err => console.error(err));
Debug
Known issues
deprecatedPackage is abandoned; last update in 2015. Use mysql2/promise or other maintained libraries.
fix
Migrate to mysql2: npm install mysql2 and use require('mysql2/promise').createPool().query().
affects: >=0
gotchaThe require() returns a single function, not an object. Using destructuring will break.
fix
Use const query = require('mysql-query-promise') without curly braces.
affects: >=0
gotchaRequires 'config' module to be installed and configured; else throws 'ENOENT: config not found'.
fix
Install config: npm install config and create config/default.js with database section.
affects: >=0
breakingNo explicit errors if connection fails; promise rejects but error messages are unclear.
fix
Wrap in try-catch or add .catch() with detailed logging.
affects: >=0
Errors
Common errors & fixes
Cannot find module 'config'
The package depends on the 'config' module for database configuration, but it's not installed.
fix
Run: npm install config
TypeError: require(...) is not a function
Using destructured import like const { query } = require('mysql-query-promise') instead of direct assignment.
fix
Use: const query = require('mysql-query-promise')
Cannot read property 'database' of undefined
The 'config' module is installed but the configuration file (default.js) is missing the 'database' key.
fix
Ensure config/default.js exports a 'database' object with connection settings.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies
mysql-query-jsrequiredCore query execution engine
configoptionalConfiguration management for database settings
Agent activity
2 hits · last 30 days
node
2
Resources
mysql-query-promise — npm install mysql-query-promise · libregistry