sql-wrap is a lightweight Node.js library (v1.3.6-flow-fix-5) that wraps node-mysql with a promise-based API, supporting Q promises alongside callbacks. It provides convenient shorthand methods like select(), insert(), update(), upsert(), and delete() that automatically generate SQL from objects, and includes streaming support via queryStream() and selectStream(). Key differentiators: automatic pagination with config objects, nested table join support via nestTables, and replication-aware pool cluster support for read/write separation. The library emits a 'result' event on queries and exposes an interface similar to node-mysql. Last updated in 2019, it is in maintenance mode with no recent activity.
npm install sql-wrapNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to create a MySQL pool, instantiate sql-wrap, and use query, select, insert, update, delete, and queryStream methods.
Migrate to mysql2/promise or use a query builder like Knex.
Use null explicitly for NULL checks; avoid undefined in where objects.
For custom LIMIT behavior, use query() instead of selectOne().
Use .then() or async/await to access the stream: const stream = await sql.queryStream(...);
Test pagination results; consider using query() with custom SQL for complex pagination.
Use `import { createNodeMySQL } from 'sql-wrap'` or `const { createNodeMySQL } = require('sql-wrap')`.Run `npm install sql-wrap` and ensure node_modules contains it.
Verify MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD environment variables or connection parameters.
Use `mysql.createPool(...)` and pass that pool to createNodeMySQL.