Registry / database / mysql-query-js

mysql-query-js

JSON →
library0.1.2jsnpmunverified

Simple MySQL query interface built on connection pools. Version 0.1.2 wraps the mysql package to provide a straightforward function for executing queries against named pools (e.g., 'master'). It automatically handles reconnection (up to 5 times by default, configurable). Notably, it uses the config module for database configuration files and was transferred from an older package (mysql-query) for npm publication. This package is rarely updated and lacks TypeScript support.

npm install mysql-query-js
INSTALL
IMPORT
SIG · MYSQL-QUERY-JS
M
mysql-query-js
databasejavascriptv0.1.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.

default (query)
✓ const query = require('mysql-query-js');
✗ import query from 'mysql-query-js';
This package is CommonJS-only. No ESM or default export supported.
pool
✓ const query = require('mysql-query-js'); query.pool;
Access the pool object via the query function's .pool property.
query function call
✓ query('SELECT * FROM users', [], 'master', (err, rows, fields) => {});
✗ query('SELECT * FROM users', ['param'], 'master', (err, rows) => {});
The callback receives three arguments: err, rows, and fields. Missing fields is common.

Shows basic usage: require the module, execute a query with parameters, and handle the result callback.

const query = require('mysql-query-js'); // Assumes config/default.js has database.master configured query('SHOW DATABASES', [], 'master', (err, rows, fields) => { if (err) { console.error(err); process.exit(1); } if (rows.length) { console.log(rows); } process.exit(0); });
Debug
Known issues
deprecatedPackage is unmaintained and no longer updated. The underlying mysql package is also deprecated in favor of mysql2.
fix
Migrate to mysql2 or use a more modern query builder like knex.
affects: >=0.1.0
gotchaThe query callback must include four parameters: err, rows, fields. Omitting 'fields' will cause errors or data loss.
fix
Ensure callback signature is (err, rows, fields) => {}.
affects: all
gotchaConfiguration is loaded from the 'config' module's default file (config/default.js). If the config module is not installed or not configured, the database connection will fail.
fix
Install the config package and create a config/default.js file with the required structure.
affects: all
Errors
Common errors & fixes
Cannot find module 'config'
The package requires the 'config' module at runtime to load database settings.
fix
Install config: npm install config. Ensure config/default.js exists.
query(...) callback with only (err, rows) - rows is undefined
The query function passes three arguments to the callback, but only two are accepted.
fix
Change the callback signature to (err, rows, fields) => {}.
Upgrade
Version history
0.1.2latest on npm
Audit
Dependencies
mysqlrequiredRelies on the mysql driver for database connections and pooling.
configoptionalUses the config module to manage database configuration files.
Agent activity
10 hits · last 30 days
node
10
Resources
mysql-query-js — npm install mysql-query-js · libregistry