A lightweight MySQL wrapper for Node.js that provides connection pooling, promise-based async methods (e.g., queryAsync, getConnectionAsync), and helper functions for building SQL queries (makeSQL, makeSQLSelect, makeSQLInsert, makeSQLUpdate, makeSQLDelete). Version 2.0.9 targets Node.js and simplifies common MySQL operations while adding safeguards such as automatic connection release warnings and transaction misuse detection. It relies on the mysql npm package and offers both callback and promise styles. Compared to alternatives like mysql2 or knex, shadow-mysql focuses on basic pooling and SQL generation without ORM features.
npm install shadow-mysqlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage: creating a pool, performing a query via callback wrapped in Promise, generating a SELECT SQL with makeSQLSelect, and escaping user input.
Call `pool.end()` after all queries finish, or use a process handler like `process.on('exit', () => pool.end())`.Wrap pool.query in a Promise manually (see quickstart). There is no built-in queryAsync.
Use `escape()` for dynamic values or switch to the mysql package's built-in placeholder `?` style with query()
Always call `conn.release()` after commit or rollback, and ensure rollback on error.
Use `const { Pool } = require('shadow-mysql');` instead.Run `npm install shadow-mysql` in your project root.
Add `return` before `connection.rollback(...)` to stop execution after error.
Verify DB_HOST, DB_USER, DB_PASS, and DB_NAME environment variables or options passed to Pool constructor.