Registry / database / mysql-oh-wait

mysql-oh-wait

JSON →
library0.19.10jsnpmunverified

mysql-oh-wait is an async/await wrapper around mysql2 that provides a single-connection-per-process guarantee, eliminating connection management boilerplate. Current stable version is 0.19.10, released as needed. Unlike raw mysql2 or mysql, it returns query results directly without callbacks or promises, and ensures only one connection exists per process to prevent resource leaks. Requires mysql2 >= 3.0.0 and saylo >= 0.5.0 as peer dependencies. Fully written in TypeScript with bundled type definitions.

npm install mysql-oh-wait
INSTALL
IMPORT
SIG · MYSQL-OH-WAIT
M
mysql-oh-wait
databasejavascriptv0.19.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.

MysqlReq
✓ import { MysqlReq } from 'mysql-oh-wait'
✗ const MysqlReq = require('mysql-oh-wait').MysqlReq
ESM-only package - no CommonJS support.
MysqlDump
✓ import { MysqlDump } from 'mysql-oh-wait'
✗ const MysqlDump = require('mysql-oh-wait');
MysqlDump is a named export, must be destructured.
default
✓ import mysqlOhWait from 'mysql-oh-wait'
✗ import { default } from 'mysql-oh-wait'
Default export is not provided; use named imports only.
MysqlReq type
✓ import type { MysqlReq } from 'mysql-oh-wait'
✗ import { MysqlReq } from 'mysql-oh-wait'
For type-only imports, use `import type` to avoid runtime overhead.

Shows a simple SELECT query with parameterized WHERE clause using MysqlReq, with async/await and error handling.

import { MysqlReq } from 'mysql-oh-wait'; // Assume DB_HOST, DB_USER, DB_PASSWORD, DB_NAME are set in environment async function main() { try { const res = await MysqlReq.query({ sql: 'SELECT * FROM MyTable WHERE ?', values: { myCol: 'myValue' } }); console.log(res); } catch (err) { console.error(err); } } main();
Debug
Known issues
breakingIn v0.17.0, the package switched to pure ESM. CommonJS require() will fail.
fix
Use import syntax instead of require().
affects: >=0.17.0
deprecatedThe `MysqlReq.execute()` method was deprecated in v0.18.0 in favor of `MysqlReq.query()` with explicit `{sql, values}` syntax.
fix
Use `.query({ sql, values })` instead of `.execute(sql, values)`.
affects: >=0.18.0
gotchaUsing `MysqlReq` without setting environment variables (DB_HOST, DB_USER, etc.) will cause a connection error.
fix
Ensure all required environment variables are set before first query.
affects: all
gotchaThe package maintains a single connection per process. Calling `MysqlReq.query()` after the connection is closed will throw 'Cannot execute query after connection closed'.
fix
Do not close the connection manually; let the package manage it.
affects: all
breakingIn v0.19.0, the peer dependency on mysql2 was updated to >=3.0.0. Using older mysql2 versions will cause runtime errors.
fix
Update mysql2 to version 3.0.0 or higher.
affects: >=0.19.0
Errors
Common errors & fixes
Cannot find module 'mysql-oh-wait'
Package not installed or not in node_modules.
fix
Run `npm install mysql-oh-wait`.
TypeError: MysqlReq.query is not a function
Incorrect import - using default import instead of named import.
fix
Use `import { MysqlReq } from 'mysql-oh-wait'`.
Error: connect ECONNREFUSED 127.0.0.1:3306
MySQL server not running or connection environment variables incorrect.
fix
Start MySQL server and verify DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, DB_NAME.
Upgrade
Version history
0.19.10latest on npm
Audit
Dependencies
mysql2requiredpeer dependency for MySQL database driver
saylorequiredpeer dependency for logging
Agent activity
6 hits · last 30 days
node
6
Resources
mysql-oh-wait — npm install mysql-oh-wait · libregistry