Registry / database / sql-query-template

sql-query-template

JSON →
library1.0.4jsnpmunverified

A simple Postgres SQL query template library with TypeScript support. Version 1.0.4. Provides tagged template literals for building parameterized SQL queries safely. No dependencies. Lightweight and focused on Postgres. Differentiates by minimalism and explicit Postgres focus compared to generic SQL builders.

npm install sql-query-template
INSTALL
IMPORT
SIG · SQL-QUERY-TEMPLATE
S
sql-query-template
databasejavascriptv1.0.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

sql
import { sql } from 'sql-query-template'
const sql = require('sql-query-template')
Package is ESM-only; CommonJS require will fail.
SQLQuery
import type { SQLQuery } from 'sql-query-template'
import { SQLQuery } from 'sql-query-template'
SQLQuery is a type, not a runtime value. Use type import.
default import
import sqt from 'sql-query-template'
const sqt = require('sql-query-template'); const { sql } = sqt
No default export; only named exports. Default import yields undefined.

Demonstrates basic usage with dynamic table name via sql.ident and parameterized value, showing generated query text and values array.

import { sql } from 'sql-query-template' const tableName = 'users' const id = 42 const query = sql`SELECT * FROM ${sql.ident(tableName)} WHERE id = ${id}` console.log(query.text) // 'SELECT * FROM "users" WHERE id = $1' console.log(query.values) // [42]
Debug
Known issues
gotchaPackage is ESM-only; CommonJS require will not work.
fix
Use import syntax instead of require.
affects: >=1.0.0
gotchaNo default export. Importing the default (e.g., import sqt from '...') yields undefined.
fix
Use named import: import { sql } from 'sql-query-template'.
affects: >=1.0.0
gotchaType SQLQuery is a type-only export; importing it as a value at runtime will cause an error.
fix
Use import type { SQLQuery } from 'sql-query-template'.
affects: >=1.0.0
Errors
Common errors & fixes
SyntaxError: Named export 'sql' not found. The requested module 'sql-query-template' is a CommonJS module, which may not support all module.exports as named exports.
Trying to import named exports from a package that appears CommonJS due to misconfiguration or using dynamic import() on ESM-only package in a CommonJS context.
fix
Use import syntax if possible, or check that your project is configured for ESM (type: 'module' in package.json).
TypeError: sql is not a function
Using default import (import sql from '...') which yields undefined.
fix
Use named import: import { sql } from 'sql-query-template'.
Module not found: Error: Can't resolve 'sql-query-template'
Package not installed or bundler configuration missing.
fix
Run npm install sql-query-template.
Upgrade
Version history
1.0.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
10
Meta
2
OpenAI (training)
1
Resources
sql-query-template — npm install sql-query-template · libregistry