Registry / database / sy-node-mysql

sy-node-mysql

JSON →
library2.0.10jsnpmunverified

A lightweight MySQL query builder for Node.js (v2.0.10, last updated 2019). Wraps mysql2 with a simple API for SELECT, INSERT, UPDATE, and DELETE operations with support for read/write splitting, connection pooling, optional big number handling, and timezone configuration. Key differentiator: built-in read-only pool support and automatic NULL handling for undefined fields. Requires Node >=6.0. Release cadence: sporadic, no recent updates.

npm install sy-node-mysql
INSTALL
IMPORT
SIG · SY-NODE-MYSQL
S
sy-node-mysql
databasejavascriptv2.0.10
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 (constructor)
const Mysql = require('sy-node-mysql'); const db = new Mysql(config);
import Mysql from 'sy-node-mysql';
This package uses CommonJS; ESM import is not supported. Use require().
mysql.select
const rows = await db.select(table, options, dbName, readonly);
const rows = await db('table').select(options);
Do not chain methods; call select on the instance directly.
mysql.get
const pool = db.get(dbName); await pool.query(sql, params);
const pool = db.get(dbName, true); // wrong second arg type
Second argument is a boolean for readonly flag, not a string. Default false.

Initializes sy-node-mysql with a config array (connection pool settings) and demonstrates select, insert, and raw query.

const Mysql = require('sy-node-mysql'); const config = [ { name: 'MY_DB', database: 'test', port: 3306, host: process.env.DB_HOST ?? 'localhost', user: process.env.DB_USER ?? 'root', password: process.env.DB_PASS ?? '', readonly: false, connectionLimit: 10 } ]; const mysql = new Mysql(config); async function run() { // Simple select const rows = await mysql.select('person', { where: { id: 1 } }, 'MY_DB'); console.log(rows); // Insert await mysql.insert('person', { name: 'John', age: 30 }, 'MY_DB'); // Direct query const result = await mysql.query('SELECT ? + ? AS sum', [1, 2], 'MY_DB'); console.log(result); } run().catch(console.error);
Debug
Known issues
deprecatedPackage has not been updated since 2019. No compatibility with newer mysql2 versions or Node >=14.
fix
Consider migrating to modern alternatives like knex, typeorm, or mysql2 directly.
affects: >=2.0.10
gotchaConfig array must have exactly one non-readonly database per name, otherwise writes may fail silently.
fix
Ensure each named db group contains exactly one entry with readonly: false (or omitted default) and any number of readonly replicas.
affects: >=2.0.0
breakingIn version 2.0.0, require('sy-node-mysql') exports a constructor, not an already-initialized instance. Old code using require('sy-node-mysql')() will break.
fix
Always use require('sy-node-mysql') to get constructor, then instantiate: new Mysql(config).
affects: >=2.0.0
gotchaThe 'update' method's insert-like behavior for upsert only supports simple ON DUPLICATE KEY UPDATE syntax; no conflict targets or partial updates.
fix
Use mysql.query for custom UPSERT statements if needed.
affects: >=1.0.0
gotchaWhen calling mysql.select with 'selectAndCount' option, the result is an object { count, rows }, not just rows. Forgot destructuring will cause runtime errors.
fix
Destructure result: const { count, rows } = await mysql.selectAndCount(...);
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: mysql.select is not a function
Attempted to call select on a non-initialized instance or on the wrong object
fix
Ensure you have created an instance: const mysql = new Mysql(config); then call mysql.select(...).
Error: Cannot find module 'sy-node-mysql'
Package not installed or missing from node_modules
fix
Run 'npm install sy-node-mysql --save' and verify package.json includes it.
Client does not support authentication protocol requested by server; consider upgrading MySQL client
Outdated mysql2 or sy-node-mysql internal mysql2 version incompatible with MySQL 8+ default auth plugin
fix
Update mysql2 to >=2.0.0 and set mysql2 default auth plugin: alter user 'user'@'host' identified with mysql_native_password by 'password';
Upgrade
Version history
2.0.10latest on npm
Audit
Dependencies
mysql2requiredUnderlying MySQL driver for connection pooling and queries
Agent activity
15 hits · last 30 days
node
12
Meta
1
OpenAI (training)
1
Resources
sy-node-mysql — npm install sy-node-mysql · libregistry