puresql is a Node.js SQL library inspired by Clojure's yesql that lets you define SQL queries in .sql files with named parameters and modifiers, then loads them as async functions. The current stable version is 1.10.0. It supports MySQL, MariaDB, PostgreSQL, MS SQL Server, and SQLite via adapters. Unlike ORMs or query builders, puresql keeps SQL raw and separate from JS logic, and supports parameter modifiers for safe interpolation, object insertion/update, dynamic conditions, and conditional clauses. Ships TypeScript definitions. Requires Node >= 6.0.0. Maintained but infrequent releases.
npm install puresqlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates loading SQL queries from a .sql file, creating a MySQL adapter, and calling queries as async functions with parameter binding.
Ensure all named parameters in the SQL are provided in the parameters object, or use optional parameters with modifiers like :*limit.
Use async/await or Promises instead of generators. See README_OLD.md for generator examples.
Only use :! for trusted values like column names or ORDER BY clauses; prefer named parameters for user input.
If using Node 16+, verify compatibility; consider pinning Node version if issues arise.
Use `const puresql = require('puresql')` or configure bundler with `esModuleInterop: true` for TypeScript.Pass all required parameters as an object, e.g., `queries.get_by_id({ id: 1 }, adapter)`.Create an adapter via `puresql.adapters.mysql(connection)` (or other database adapter) and pass it as second argument to query functions.