Registry / database / mysql-chassis

mysql-chassis

JSON →
library5.0.0jsnpmunverified

Promise-based wrapper for mysqljs (node-mysql) providing convenience methods like query(), select(), insert(), update(), delete(), queryFile(), selectFile(), selectWhere(), insertMultiple(), insertIgnore(), insertUpdate(), and a middleware layer. Currently at version 5.0.0. It supports external SQL files, named bind parameters (like PDO), automatic LIMIT 1 result unwrapping, EJS-based SQL templates, and JS-to-SQL transforms. Unlike raw mysqljs, it is promise-based and includes retry logic for connections.

npm install mysql-chassis
INSTALL
IMPORT
SIG · MYSQL-CHASSIS
M
mysql-chassis
databasejavascriptv5.0.0
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.

MySQL
import MySQL from 'mysql-chassis'
const MySQL = require('mysql-chassis')
Package exports a default export (ES6). In CommonJS, you must use .default: const MySQL = require('mysql-chassis').default
MySQL
import MySQL from 'mysql-chassis'
import { MySQL } from 'mysql-chassis'
Named import (curly braces) is incorrect; it's a default export.
MySQL
const MySQL = require('mysql-chassis').default
const MySQL = require('mysql-chassis')
CommonJS require returns an object with a .default property because the package uses ESM default exports.

Shows how to import, create a connection, wait for success, and run a simple query using promises.

import MySQL from 'mysql-chassis'; const db = new MySQL({ host: process.env.DB_HOST ?? 'localhost', database: process.env.DB_NAME ?? 'test', user: process.env.DB_USER ?? 'root', password: process.env.DB_PASS ?? '' }); db.on('connectionSuccess', () => { console.log('Connected to MySQL'); db.query('SELECT 1 + 1 AS solution') .then(results => console.log('Result:', results[0].solution)) .catch(err => console.error(err)); }); db.on('connectionError', err => console.error('Connection error:', err));
Debug
Known issues
breakingVersion >=5.0.0 drops support for Node.js <10 and may have breaking changes to transform/middleware APIs.
fix
Check CHANGELOG for specific API changes; upgrade Node.js to >=10.
affects: >=5.0.0
deprecatedCallback-style usage is deprecated; all operations return promises.
fix
Use .then()/.catch() or async/await instead of callbacks.
affects: >=4.0.0
gotchaConnection options (password, host) are merged with mysqljs options; omitting password defaults to undefined (mysqljs may reject).
fix
Always explicitly provide password (even empty string) for clarity.
affects: >=1.0.0
gotchaThe default sqlPath is './sql'; if directory does not exist, queryFile/selectFile will throw.
fix
Ensure the sqlPath directory exists or set it explicitly with absolute path.
affects: >=1.0.0
Errors
Common errors & fixes
MySQL is not a constructor
CommonJS require without .default
fix
Use const MySQL = require('mysql-chassis').default;
Cannot find module './sql'
Missing SQL file directory or incorrect sqlPath option
fix
Set sqlPath to an existing directory containing .sql files (e.g., sqlPath: path.join(__dirname, 'sql'))
ER_ACCESS_DENIED_ERROR: Access denied for user
Missing or incorrect password/username
fix
Verify DB_HOST, DB_USER, DB_PASS environment variables or constructor options
Upgrade
Version history
5.0.0latest on npm
Audit
Dependencies
mysqlrequiredUnderlying MySQL driver library (mysqljs)
Agent activity
4 hits · last 30 days
node
4
Resources
mysql-chassis — npm install mysql-chassis · libregistry