A Node.js library for reading named SQL statements from .sql files and using named parameters in prepared statements. Version 7.0.0 supports PostgreSQL, MySQL/MariaDB, and raw/SQLite drivers. It parses SQL files with named queries and converts named parameters (e.g. :name, $name) into database-specific parameterized formats. Key differentiator: it handles multiple database dialects, supports quoted strings, missing parameter handling, and throws on duplicate query names. Released on npm, maintained, with active development history.
npm install yesqlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates reading SQL from files and using named parameters with PostgreSQL.
Ensure each query name in .sql files is unique, remove or rename duplicates.
If you rely on missing parameters being an error, do not set useNullForMissing: true. If you want NULLs, continue using it.
Pass a directory path: yesql('./sql/'), not yesql('./sql/query.sql').Use the correct parameter syntax for your database type. For PG/MySQL use :name; for SQLite use $name; for raw SQL use ?.
npm install yesql
Use sql.getPokemon({param: value}) instead of sql.getPokemon.Rename one of the queries to have a unique name.
No dependency data recorded yet.