Registry / database / msq
library1.0.1jsnpmunverified

A lightweight MySQL query manager built on top of the popular mysql package (v2.x). Version 1.0.1 provides a simple wrapper around mysql.createPool offering query and stored procedure methods with support for generator-based control flow (e.g., co + thunkify). It does not include any built-in promise or async/await support, making it primarily suited for legacy callback or generator patterns. The package is relatively unmaintained and lacks modern features like connection string parsing or transaction helpers, pushing users toward more actively developed alternatives such as mysql2 or knex.

npm install msq
INSTALL
IMPORT
SIG · MSQ
M
msq
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.

default
const msq = require('msq')
import msq from 'msq'; // ESM not supported
Package exposes a CommonJS default export only. Use require() for importing.
model.query
const model = msq(config); model.query(sql, callback)
model.query(sql) // missing callback leads to timeout
query() expects a callback as second argument. Without it, the query will hang and eventually timeout.
model.proc
const model = msq(config); model.proc(name, params, callback)
model.proc(name, callback) // params array must be provided, even if empty
Second argument must be an array of parameters. Use empty array [] if no parameters.

Demonstrates creating a connection pool, running a query and a stored procedure using generator-based control flow with co and thunkify-array.

const msq = require('msq'); const co = require('co'); const thunkify = require('thunkify-array'); const config = { host: process.env.DB_HOST ?? 'localhost', user: process.env.DB_USER ?? 'root', password: process.env.DB_PASS ?? '', database: process.env.DB_NAME ?? 'test', port: parseInt(process.env.DB_PORT ?? '3306') }; const model = msq(config); co(function*() { try { const rows = yield thunkify(model.query)('SELECT 1 AS result'); console.log('Query result:', rows); const procResult = yield thunkify(model.proc)('myProcedure', ['param1']); console.log('Procedure result:', procResult); } catch (err) { console.error('Error:', err); } });
Debug
Known issues
deprecatedThis package uses generators and thunks, which are outdated patterns. Consider migrating to async/await with mysql2.
fix
Use mysql2 with promise-based queries: import mysql2 from 'mysql2/promise'; const pool = mysql2.createPool(config); const [rows] = await pool.query('SELECT ?', [1]);
affects: >=1.0.0
breakingThe package depends on the deprecated 'mysql' npm package, which is no longer actively maintained and has known security issues (CVE-2022-36223, CVE-2023-22102).
fix
Replace with 'mysql2' which is a modern fork with improved security and better performance.
affects: >=1.0.0
gotchaquery() and proc() methods require a callback as the last argument. Omitting it causes the query to never execute or the process to hang.
fix
Always pass a callback (or use thunkify/promisify). Example: model.query('SELECT 1', (err, rows) => { ... })
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: model.query(...) is not a function
msq() not called with config before calling model methods.
fix
Ensure you call msq(config) and assign the result to model: const model = msq(config);
Error: Cannot find module 'msq'
Package not installed or incorrect import path.
fix
Run 'npm install msq' and use require('msq') (not import).
Error: Connection lost: The server closed the connection.
MySQL server idle timeout or connection pool exhaustion.
fix
Check pool configuration: increase waitForConnections or connectionLimit; or implement query retry logic.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies
mysqlrequiredRuntime dependency: used for creating connection pools and executing queries.
Agent activity
4 hits · last 30 days
node
4
Resources
packagemsq
msq — npm install msq · libregistry