{"id":43316,"library":"mysql-oh-wait","title":"mysql-oh-wait","description":"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.","status":"active","version":"0.19.10","language":"javascript","source_language":"en","source_url":"https://github.com/gbili/mysql-oh-wait","tags":["javascript","nodejs","mysql","query","params","typescript"],"install":[{"cmd":"npm install mysql-oh-wait","lang":"bash","label":"npm"},{"cmd":"yarn add mysql-oh-wait","lang":"bash","label":"yarn"},{"cmd":"pnpm add mysql-oh-wait","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency for MySQL database driver","package":"mysql2","optional":false},{"reason":"peer dependency for logging","package":"saylo","optional":false}],"imports":[{"note":"ESM-only package - no CommonJS support.","wrong":"const MysqlReq = require('mysql-oh-wait').MysqlReq","symbol":"MysqlReq","correct":"import { MysqlReq } from 'mysql-oh-wait'"},{"note":"MysqlDump is a named export, must be destructured.","wrong":"const MysqlDump = require('mysql-oh-wait');","symbol":"MysqlDump","correct":"import { MysqlDump } from 'mysql-oh-wait'"},{"note":"Default export is not provided; use named imports only.","wrong":"import { default } from 'mysql-oh-wait'","symbol":"default","correct":"import mysqlOhWait from 'mysql-oh-wait'"},{"note":"For type-only imports, use `import type` to avoid runtime overhead.","wrong":"import { MysqlReq } from 'mysql-oh-wait'","symbol":"MysqlReq type","correct":"import type { MysqlReq } from 'mysql-oh-wait'"}],"quickstart":{"code":"import { MysqlReq } from 'mysql-oh-wait';\n\n// Assume DB_HOST, DB_USER, DB_PASSWORD, DB_NAME are set in environment\nasync function main() {\n  try {\n    const res = await MysqlReq.query({ sql: 'SELECT * FROM MyTable WHERE ?', values: { myCol: 'myValue' } });\n    console.log(res);\n  } catch (err) {\n    console.error(err);\n  }\n}\nmain();","lang":"typescript","description":"Shows a simple SELECT query with parameterized WHERE clause using MysqlReq, with async/await and error handling."},"warnings":[{"fix":"Use import syntax instead of require().","message":"In v0.17.0, the package switched to pure ESM. CommonJS require() will fail.","severity":"breaking","affected_versions":">=0.17.0"},{"fix":"Use `.query({ sql, values })` instead of `.execute(sql, values)`.","message":"The `MysqlReq.execute()` method was deprecated in v0.18.0 in favor of `MysqlReq.query()` with explicit `{sql, values}` syntax.","severity":"deprecated","affected_versions":">=0.18.0"},{"fix":"Ensure all required environment variables are set before first query.","message":"Using `MysqlReq` without setting environment variables (DB_HOST, DB_USER, etc.) will cause a connection error.","severity":"gotcha","affected_versions":"all"},{"fix":"Do not close the connection manually; let the package manage it.","message":"The package maintains a single connection per process. Calling `MysqlReq.query()` after the connection is closed will throw 'Cannot execute query after connection closed'.","severity":"gotcha","affected_versions":"all"},{"fix":"Update mysql2 to version 3.0.0 or higher.","message":"In v0.19.0, the peer dependency on mysql2 was updated to >=3.0.0. Using older mysql2 versions will cause runtime errors.","severity":"breaking","affected_versions":">=0.19.0"}],"env_vars":null,"search_vec":"'0.19.10':32 '0.5.0':67 '3.0.0':64 'around':13 'async/await':11 'boilerpl':27 'bundl':76 'callback':47 'connect':20,25,54 'current':28 'definit':78 'depend':70 'direct':45 'elimin':24 'ensur':51 'exist':55 'fulli':71 'guarante':23 'javascript':79 'leak':61 'manag':26 'mysql':2,6,40,81 'mysql-oh-wait':1,5 'mysql2':14,38,63 'need':35 'nodej':80 'oh':3,7 'one':53 'param':83 'peer':69 'per':21,56 'prevent':59 'process':22,57 'promis':49 'provid':16 'queri':43,82 'raw':37 'releas':33 'requir':62 'resourc':60 'result':44 'return':42 'saylo':66 'singl':19 'single-connection-per-process':18 'stabl':29 'type':77 'typescript':74,84 'unlik':36 'version':30 'wait':4,8 'without':46 'wrapper':12 'written':72","created_at":"2026-06-05T16:59:13.315073+00:00","updated_at":"2026-06-05T16:59:13.315073+00:00","problems":[{"fix":"Run `npm install mysql-oh-wait`.","cause":"Package not installed or not in node_modules.","error":"Cannot find module 'mysql-oh-wait'"},{"fix":"Use `import { MysqlReq } from 'mysql-oh-wait'`.","cause":"Incorrect import - using default import instead of named import.","error":"TypeError: MysqlReq.query is not a function"},{"fix":"Start MySQL server and verify DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, DB_NAME.","cause":"MySQL server not running or connection environment variables incorrect.","error":"Error: connect ECONNREFUSED 127.0.0.1:3306"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/gbili/mysql-oh-wait#readme","github":"https://github.com/gbili/mysql-oh-wait","docs":null,"changelog":null,"pypi":null,"npm":"mysql-oh-wait","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}