Registry / database / easy-mysql

easy-mysql

JSON →
library1.0.3jsnpmunverified

A lightweight MySQL query wrapper for Node.js that simplifies connection pooling and query execution. Built on top of node-mysql, it provides helper methods like get_one and get_all to reduce boilerplate code for common database operations. Current stable version is 1.0.3 (last updated 2011). Low release cadence; no longer actively maintained. Differentiates by offering three connection modes (direct, custom pool, built-in pool) and concise API for single-row or multi-row queries.

npm install easy-mysql
INSTALL
IMPORT
SIG · EASY-MYSQL
E
easy-mysql
databasejavascriptv1.0.3
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.

EasyMySQL
import EasyMySQL from 'easy-mysql'
const EasyMySQL = require('easy-mysql')
ESM import style used for modern Node.js; package does not ship TypeScript types.
EasyMySQL.connect
EasyMySQL.connect(settings)
EasyMySQL.connect_with_easy_pool(settings)
connect_with_easy_pool is for built-in pooling, not direct connection.
easy_mysql.get_one
easy_mysql.get_one(sql, params, callback)
easy_mysql.get_one(sql, callback, params)
Callback must be the third argument after parameters.

Demonstrates direct connection, get_one, get_all, and execute methods using easy-mysql.

const EasyMySQL = require('easy-mysql'); // Direct connection (not recommended for production) const settings = { user: 'myuser', password: 'mypass', database: 'mydb' }; const db = EasyMySQL.connect(settings); // Query for a single row const sql = 'SELECT * FROM widgets WHERE id = ?'; db.get_one(sql, [1], (err, result) => { if (err) { console.error(err); return; } console.log(result); }); // Query for multiple rows const sql2 = 'SELECT * FROM widgets WHERE active = ?'; db.get_all(sql2, [true], (err, results) => { if (err) { console.error(err); return; } console.log(results); }); // Execute an arbitrary query db.execute('UPDATE widgets SET name = ? WHERE id = ?', ['newName', 1], (err, res) => { if (err) console.error(err); });
Debug
Known issues
deprecatedPackage not updated since 2011 and depends on outdated node-mysql driver.
fix
Migrate to modern MySQL client like mysql2 or @mysql/xdevapi.
affects: >=1.0.0
gotchaget_one returns null for no results, get_all returns empty array. Do not assume get_all will never be null.
fix
Always check err before using results; use callback signature (err, result).
affects: >=0.0.0
gotchaconnect_with_easy_pool creates a pool with default settings; pool_size option may not work as expected in all versions.
fix
Use a custom pool with generic-pool for more control.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: EasyMySQL.connect is not a function
Using import/require incorrectly; package exports a constructor, not a namespace.
fix
Use `const EasyMySQL = require('easy-mysql');` then call `EasyMySQL.connect(...)`.
Error: ER_ACCESS_DENIED_ERROR: Access denied for user
Incorrect credentials or missing host/port in settings.
fix
Ensure settings object includes host, port (default 3306), user, password, and database.
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies
mysqlrequiredUnderlying MySQL driver used by easy-mysql for all database operations.
generic-pooloptionalProvides the built-in connection pooling (node-pool) used in connect_with_easy_pool.
Agent activity
5 hits · last 30 days
node
4
Resources
easy-mysql — npm install easy-mysql · libregistry