$1 or ? placeholders are replaced by the JavaScript values they are bound to.
It understands postgres.js, Bun.sql, pg, mysql2, better-sqlite3, bun:sqlite, Prisma’s raw queries, Neon, slonik and kysely.
pgsqlParser uses pgsql-ast-parser, a peer dependency you install yourself. Without a parser the plugin still recognises SQL call sites but shows the SQL text as it is. You can also pass a getter to load the parser lazily.
Examples
A tagged template
English
pg with placeholders
English
Upserts
English
An update without a WHERE clause
English
What it covers
- Tagged templates (
sql,Bun.sql, Prisma’s$queryRawand$executeRaw, slonik),sql.unsafe, and kysely’s.execute(db). - Query functions on database handles such as
db,pool,clientandtx, with$1,?and$nameplaceholders, value arrays, and{ text, values }objects. - Prepared statements in
better-sqlite3andbun:sqlite, including statements declared once and run later. - SQL constants, narrated where they are declared and where they run.
- Selects with joins, grouping, window functions,
CASE, subqueries, CTEs (including recursive ones) andUNION, plus inserts, updates, deletes, upserts,RETURNING, row locking and JSONB operators.
sql template is left to the Drizzle plugin.
Translating
The English phrasebook is exported asen and typed as SqlPhrases.