Registry / database / mysql-toolbox

mysql-toolbox

JSON →
library1.6.4jsnpmunverified

Object-oriented helper for MySQL interactions, version 1.6.4. Provides a simple query builder and connection management for Node.js MySQL applications. Release cadence appears low (last update may be older). Differentiates by offering a more OOP-style approach compared to raw mysql2 or knex, but is less feature-rich and maintained. Not a full ORM; minimal abstraction layer for simple queries.

npm install mysql-toolbox
INSTALL
IMPORT
SIG · MYSQL-TOOLBOX
M
mysql-toolbox
databasejavascriptv1.6.4
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-toolbox'
const MySQL = require('mysql-toolbox')
Default export is a class; ESM and CJS both supported, but import preferred.
QueryBuilder
import { QueryBuilder } from 'mysql-toolbox'
import QueryBuilder from 'mysql-toolbox'
Named export, not default.
Connection
import { Connection } from 'mysql-toolbox'
Type interface for TypeScript users; not a runtime export.

Shows basic setup with environment variables and a parameterized query.

import { MySQL } from 'mysql-toolbox'; const db = new MySQL({ host: process.env.DB_HOST ?? 'localhost', user: process.env.DB_USER ?? 'root', password: process.env.DB_PASS ?? '', database: process.env.DB_NAME ?? 'test' }); db.query('SELECT * FROM users WHERE id = ?', [1]) .then(rows => console.log(rows)) .catch(err => console.error(err)); db.close();
Debug
Known issues
breakingv1.6.0 changed query() to return Promise<RowDataPacket[]> instead of raw arrays.
fix
Update code to handle RowDataPacket objects or use .map() to extract values.
affects: >=1.6.0
breakingConnection pooling removed in v1.5.0; use MySQL class directly for single connections.
fix
Remove pool configuration; each MySQL instance opens one connection.
affects: >=1.5.0
deprecatedQueryBuilder is deprecated since v1.6.0 and will be removed in v2.0. Use raw query strings or switch to another library.
fix
Replace QueryBuilder calls with direct SQL strings.
affects: >=1.6.0 <2.0.0
gotchaMySQL class does not support reconnection; connection errors will not automatically retry.
fix
Implement manual reconnection logic or use a driver with built-in reconnect (e.g., mysql2 with pool).
affects: all
gotchaLibrary depends on mysql2 package; ensure it is installed in your project.
fix
Run 'npm install mysql2' alongside mysql-toolbox.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: MySQL is not a constructor
Using default import from CommonJS without destructuring.
fix
Use 'const { MySQL } = require('mysql-toolbox');' or ES6 import.
Cannot find module 'mysql2'
Peer dependency mysql2 not installed.
fix
Install mysql2: npm install mysql2
TypeError: db.query(...).then is not a function
Using callback style with older API version.
fix
Upgrade to v1.6+ or use callbacks if on older version.
Upgrade
Version history
1.6.4latest on npm
Audit
Dependencies
mysql2requiredUnderlying MySQL driver for database connections and queries
Agent activity
5 hits · last 30 days
node
4
Resources
mysql-toolbox — npm install mysql-toolbox · libregistry