Registry / database / stackpress-sql

stackpress-sql

JSON →
library0.10.5jsnpmunverified

SQL library for the Stackpress framework (v0.10.5), primarily used with Node.js and TypeScript. It provides a simple query builder and database abstraction layer, supporting multiple dialects (PostgreSQL, MySQL, SQLite). Active development, frequent releases. Heavier than alternatives like Knex but integrated with the Stackpress ecosystem for CLI, migrations, and seeders.

npm install stackpress-sql
INSTALL
IMPORT
SIG · STACKPRESS-SQL
S
stackpress-sql
databasejavascriptv0.10.5
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.

createConnection
import { createConnection } from 'stackpress-sql';
const createConnection = require('stackpress-sql').createConnection;
ESM-only package; use named import.
sql
import { sql } from 'stackpress-sql';
import sql from 'stackpress-sql';
sql is a named export, not default.
ConnectionConfig
import type { ConnectionConfig } from 'stackpress-sql';
Type import for TypeScript users.

Creates an in-memory SQLite connection, runs a simple query, and closes the connection.

import { createConnection, sql } from 'stackpress-sql'; const connection = createConnection({ type: 'sqlite', database: ':memory:', }); await connection.query(sql`SELECT 1 AS test`).then(rows => { console.log(rows); }); await connection.close();
Debug
Known issues
breakingv0.9.x to v0.10.x: Removed deprecated `queryRaw` method; use `query` with `sql` tagged template literal instead.
fix
Replace `connection.queryRaw('SELECT 1')` with `connection.query(sql\`SELECT 1\`)`.
affects: >=0.9.0 <0.10.0
deprecated`close()` callback-style in v0.5.x; use async `close()` returning a promise in v0.10.x.
fix
Use `await connection.close()` instead of passing a callback.
affects: >=0.5.0 <0.10.0
gotcha`sql` tagged template literal is case-sensitive; `SQL` will not work.
fix
Always import `sql` exactly as `sql` (lowercase).
affects: >=0.1.0
gotchaIn-memory SQLite connections are closed on garbage collection; always await `close()` to ensure proper cleanup.
fix
Explicitly call `await connection.close()` when done.
affects: >=0.1.0
deprecated`createPool` is deprecated since v0.8.0; use `createConnection` with connection pooling behavior instead.
fix
Use `createConnection({ type: 'postgres', pool: true })` to enable pooling.
affects: >=0.8.0
Errors
Common errors & fixes
TypeError: connection.query is not a function
Importing wrong export or using CJS require without default import workaround.
fix
Use ESM import: `import { query } from 'stackpress-sql';` (not `connection.query`). Ensure `createConnection` returns a connection object with a `query` method.
SyntaxError: Cannot use import statement outside a module
Running TypeScript/ESM code without proper module configuration.
fix
Set `"type": "module"` in package.json or use `.mjs` extension.
Error: sql`...` is not a function
Importing `sql` as default instead of named export.
fix
Change `import sql from 'stackpress-sql'` to `import { sql } from 'stackpress-sql'`.
Upgrade
Version history
0.10.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
12
Meta
1
OpenAI (training)
1
Resources
stackpress-sql — npm install stackpress-sql · libregistry