Registry / database / mysql-wrap-production

mysql-wrap-production

JSON →
library0.10.1jsnpmunverified

Mysql-wrap-production is a lightweight promise-based wrapper for the node-mysql driver, providing helper methods for SELECT, INSERT, UPDATE, DELETE, streaming, and pagination. Version 0.10.1, last updated in 2017, is in maintenance mode. It only accepts poolCluster connections and returns promises (no callbacks). Light dependency on node-mysql and q promises.

npm install mysql-wrap-production
INSTALL
IMPORT
SIG · MYSQL-WRAP-PRODUCT
M
mysql-wrap-production
databasejavascriptv0.10.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.

createNodeMySQL
const { createNodeMySQL } = require('mysql-wrap-production');
import { createNodeMySQL } from 'mysql-wrap-production';
CommonJS only; no ESM or default export.
createNodeMySQL
const createMySQL = require('mysql-wrap-production');
const createMySQL = require('mysql-wrap-production').createNodeMySQL;
The module exports the function directly, not as a named export.
CreateNodeMySQL
const { createNodeMySQL } = require('mysql-wrap-production');
CommonJS only; named import is not available in TypeScript without `esModuleInterop`.

Creates a MySQL pool, wraps it with mysql-wrap-production, and executes a simple SELECT query.

const mysql = require('mysql'); const createNodeMySQL = require('mysql-wrap-production'); const pool = mysql.createPool({ host: 'localhost', user: 'root', password: process.env.MYSQL_PASSWORD ?? '' }); const sql = createNodeMySQL(pool); sql.query('SELECT 1 AS test') .then(res => console.log(res)) .catch(err => console.error(err));
Debug
Known issues
deprecatedPackage uses the deprecated node-mysql driver (mysql npm package). Use mysql2 instead for continued support and modern features.
fix
Replace mysql with mysql2 and use mysql2.createPool() instead of mysql.createPool().
affects: all
gotchaThe `one` method appends 'LIMIT 1' if no LIMIT clause is present, but does not handle SQL injection if the SQL statement contains user input.
fix
Always sanitize user input or use parameterized queries via `sql.query('...', [values])`.
affects: all
breakingThis version only accepts poolCluster connection options, not a simple pool. Using a single pool will throw an error.
fix
Use mysql.createPoolCluster() and add nodes, or use an older version (0.9.x) if you need single pool support.
affects: >=0.10.0
deprecatedThe package relies on the 'q' promise library, which is deprecated and no longer maintained. Consider migrating to native promises.
fix
Use version 0.9.x which returns native promises, or switch to a more modern wrapper like 'mysql2/promise'.
affects: all
gotchaThe `selectStream` method returns a promise that resolves to a stream object, but the stream may emit 'error' events that need to be handled separately.
fix
Always attach an error handler to the stream: `stream.on('error', err => {})`.
affects: all
Errors
Common errors & fixes
Cannot find module 'mysql-wrap-production'
Package not installed or not found in node_modules.
fix
Run `npm install mysql-wrap-production` in your project directory.
createNodeMySQL is not a function
You called require() but didn't assign the returned function to a variable correctly.
fix
Use `const createNodeMySQL = require('mysql-wrap-production');` (no destructuring).
TypeError: sql.query is not a function
You passed a pool instead of a poolCluster, or you used an unsupported connection method.
fix
Ensure you use mysql.createPoolCluster() and call `createNodeMySQL(poolCluster, { replication: {...} })`.
Expected a callback or promise but got undefined
Some methods may not return a promise if called with a callback argument. This version only supports promises, not callbacks.
fix
Remove callback arguments and use `.then()`/`.catch()` or `await`.
Upgrade
Version history
0.10.1latest on npm
Audit
Dependencies
mysqlrequiredunderlying MySQL driver; required to create pool/poolCluster
qrequiredpromise library used internally; returned from all async methods
Agent activity
4 hits · last 30 days
node
4
Resources