Type-safe {{variable}} templating for .sql files with built-in SQL injection protection. Current stable version is 0.3.4, released under MIT license. Zero runtime dependencies, ships TypeScript types. Supports schema-based validation with type inference, custom schema types (identifier, enum, ISO date, UUID, S3 path, arrays, nullable), and compatibility with SQL engines that treat backslash as literal in strings (Athena, Trino, PostgreSQL). Differentiates from other SQL template libraries by focusing on safety and validation, not just interpolation.
npm install sql-renderNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to define a query with schema validation and execute it with typed parameters.
Use absolute paths or ensure consistent CWD. Alternatively, use a tool like path-finding to resolve relative to __dirname.
Check for empty array before calling getEvents, or use a conditional to omit the clause.
Always check the errors property on the result object before using sql.
Update imports to 'sql-render' or use the newer API.
Install the package: npm install sql-render. Use ESM import syntax: import { defineQuery } from 'sql-render'.Ensure you call defineQuery and use the returned function: const getEvents = defineQuery(...). Do not import getEvents directly.
Use a valid SQL identifier (e.g., table_name or schema.table).
No dependency data recorded yet.