Registry / database / mysqlutil

mysqlutil

JSON →
library0.1.28jsnpmunverified

A minuscule wrapper around the popular node-mysql (mysql) package for Node.js. Version 0.1.28 is the latest stable release (last updated 2016-01-03). It provides a simplified API for MySQL connections and query execution, supporting connection pooling, multiple statement execution, and result formatting. Unlike more modern alternatives (e.g., mysql2, knex), mysqlutil is a thin convenience layer, leaving full control to the user. No longer actively maintained.

npm install mysqlutil
INSTALL
IMPORT
SIG · MYSQLUTIL
M
mysqlutil
databasejavascriptv0.1.28
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.

mysqlutil
const mysqlutil = require('mysqlutil');
import mysqlutil from 'mysqlutil';
CommonJS only; no ESM support. Default export is the factory function.
Database
const Database = require('mysqlutil').Database;
import { Database } from 'mysqlutil';
Database class is a named export, but the package uses CommonJS. Use destructuring from require.
ResultSet
const ResultSet = require('mysqlutil').ResultSet;
const resultSet = require('mysqlutil').resultSet;
Export name is capitalized 'ResultSet'.

Create a connection pool, execute a simple query, and log the result.

const mysqlutil = require('mysqlutil'); const db = mysqlutil.createPool({ host: process.env.DB_HOST ?? 'localhost', user: process.env.DB_USER ?? 'root', password: process.env.DB_PASS ?? '', database: process.env.DB_NAME ?? 'test', connectionLimit: 10 }); db.query('SELECT 1 AS solution', function(err, results) { if (err) throw err; console.log('The solution is: ', results[0].solution); db.end(); });
Debug
Known issues
deprecatedThe package is no longer actively maintained as of 2016.
fix
Consider migrating to mysql2 or knex for long-term support.
affects: >=0
gotchaAll callbacks follow Node.js convention (err, results) but `results` may be an array of arrays for multiple statements.
fix
Check if `results` is an array of arrays when using multiple statements.
affects: >=0
breaking0.1.20 changed the signature of `query` to support multiple statements.
fix
Update callbacks to handle array of result sets.
affects: >=0.1.20
Errors
Common errors & fixes
TypeError: mysqlutil.createPool is not a function
Incorrect import; factory function is the default export.
fix
Use `const mysqlutil = require('mysqlutil');` then `mysqlutil.createPool(...)`.
Error: Connection lost: The server closed the connection.
MySQL server timed out idle connection.
fix
Enable auto-reconnect or increase wait_timeout on MySQL server.
Upgrade
Version history
0.1.28latest on npm
Audit
Dependencies
mysqlrequiredCore dependency providing MySQL driver; mysqlutil wraps the mysql module.
Agent activity
4 hits · last 30 days
node
4
Resources
mysqlutil — npm install mysqlutil · libregistry