MySQL wrapper for Sand.js applications providing convenience functions like autoloading config, automatic connection cleanup, and promise-based querying. Current version 2.2.6 (stable, no recent updates). Wraps node-mysql with built-in query, selectOne, insert, and update builders. Automatically attaches to sand.ctx.mysql when sand-http is loaded, managing connection lifecycle per request. Config via config/mysql.js file. Key differentiator: tight Sand.js integration with automatic context injection; no direct MySQL driver usage—user relies on sand infrastructure.
npm install sand-mysqlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to run queries using the auto-injected sand.ctx.mysql connection in a Sand.js app, including query and selectOne methods.
Always use the bindings array for user input; never concatenate values directly into SQL strings.
Ensure sand-http is included in your package.json and loaded before using sand.ctx.mysql, or manually create a connection via sand.mysql.createConnection().
Create a config/mysql.js file with valid connection options (host, user, password, database).
If you need result transformation for all operations, implement separate hooks per method or use the query() method exclusively.
Install sand-http and ensure it is required before using sand.ctx.mysql, or create a custom connection with sand.mysql.createConnection().
Check the host property in config/mysql.js; ensure the MySQL server is running and accessible from your application.
Do not reuse connections across requests; use sand.ctx.mysql which is scoped per request and cleaned up automatically.
Verify the user, password, and host in config/mysql.js. Check that the user has access from the specified host.