Pure SQL (v1.1.0-beta5) is a lightweight Node.js library that enables writing SQL queries as pure SQL template files and using them directly in JavaScript. It parses SQL files containing named queries and compiles them into parameterized query strings with argument arrays. Supports PostgreSQL (pg) and other SQL dialects via configurable parameter placeholders. Key differentiators: minimal abstraction (no ORM-like layers), template-based approach similar to HugSQL, support for repeating arguments and table/column placeholders via :!table and :column** syntax. Currently in beta, with slow release cadence.
npm install pure-sqlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows loading SQL templates from file, executing a named query with pg, and customizing parameter placeholder for MySQL.
Check CHANGELOG on GitHub before upgrading.
Pass '.sql' as second argument, not 'sql'.
Use query.map({ id: 1 }) to get { query: '...$1...', args: [1] }.Prefer .map() if available.
Run 'npm install pure-sql' and verify package name in package.json.
Use: import { PG } from 'pure-sql' or const PG = require('pure-sql').PGCall templates = PG.parseTemplateFiles(__dirname + '/sql', '.sql'); ensure directory exists.