Registry / database / sqlite-tag-spawned

sqlite-tag-spawned

JSON →
library0.7.1jsnpmunverified

A lightweight SQLite library that provides tagged template literal queries (same API as sqlite-tag) but without the native sqlite3 module dependency, using spawned sqlite3 process with -json output. Current stable version is v0.7.1, with irregular releases. Key differentiators: works in environments where native modules cannot compile (e.g., restricted CI, serverless), requires only the sqlite3 CLI (v3.33+), and supports transactions, IN clauses via arrays, and :memory: databases (Node 16+). Performance is similar to native sqlite3 but each query is a spawn call except transactions.

npm install sqlite-tag-spawned
INSTALL
IMPORT
SIG · SQLITE-TAG-SPAWNED
S
sqlite-tag-spawned
databasejavascriptv0.7.1
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.

default
import SQLiteTagSpawned from 'sqlite-tag-spawned'
const SQLiteTagSpawned = require('sqlite-tag-spawned')
ESM default import is preferred; CommonJS require() works but the default export is wrapped.
query
const { query } = SQLiteTagSpawned('./db.sql')
const query = SQLiteTagSpawned.query('./db.sql')
The exported object from the function call contains query, get, all, raw, transaction.
transaction
const populate = transaction(); await populate.commit();
await transaction`INSERT ...`(commit)
Transactions return a function that must be called with tagged literals; commit is an async method.
type imports
import type { SQLiteTagSpawnedOptions } from 'sqlite-tag-spawned'
import { SQLiteTagSpawnedOptions } from 'sqlite-tag-spawned'
Options type is not a value; must be imported with 'type' keyword in TypeScript.

Shows basic usage with in-memory database: create table, transaction, query all rows, and fetch single row.

import SQLiteTagSpawned from 'sqlite-tag-spawned'; const { query, get, all, transaction } = SQLiteTagSpawned(':memory:'); await query`CREATE TABLE IF NOT EXISTS test (id INTEGER PRIMARY KEY, value TEXT)`; const insert = transaction(); insert`INSERT INTO test (value) VALUES ('hello')`; insert`INSERT INTO test (value) VALUES ('world')`; await insert.commit(); const rows = await all`SELECT * FROM test`; console.log(rows); // [{ id: 1, value: 'hello' }, { id: 2, value: 'world' }] const single = await get`SELECT value FROM test WHERE id = 1`; console.log(single); // { value: 'hello' }
Debug
Known issues
gotcha:memory: database uses a temporary file created at runtime; it is not truly in-memory and persists until Node process exits. Requires Node 16+.
fix
Use a named file instead of ':memory:' for persistence; for ephemeral data, ensure process cleanup.
affects: >=0.0.0
gotchaEach query spawns a separate sqlite3 process (except transactions). In high-frequency query scenarios, this can be slower than native sqlite3 and may hit system limits on spawned processes.
fix
Use the 'persistent' option to keep the sqlite3 process alive, or consider sqlite-tag (native binding) for performance-critical apps.
affects: >=0.0.0
breakingRequires SQLite 3.33 or higher because it uses the -json output mode. Older sqlite3 versions will fail silently or output unexpected text.
fix
Ensure sqlite3 CLI version >= 3.33. Check with 'sqlite3 --version'.
affects: >=0.0.0
gotchaThe 'bin' option expects the path to the sqlite3 executable; if not set, it assumes 'sqlite3' is in PATH. Custom executables may not support all flags.
fix
Verify the custom executable supports -json, -init, and -bail flags.
affects: >=0.0.0
Errors
Common errors & fixes
Error: /usr/bin/sqlite3: /usr/lib/x86_64-linux-gnu/libsqlite3.so.0: version `SQLITE_3.33' not found
The installed sqlite3 CLI is older than version 3.33.
fix
Install a newer version of sqlite3 via your package manager or from https://sqlite.org/download.html.
Error: spawn sqlite3 ENOENT
The 'sqlite3' executable is not found in PATH or the specified bin path is incorrect.
fix
Install sqlite3 CLI or set the 'bin' option to the correct executable path.
TypeError: (0 , SQLiteTagSpawned) is not a function
CommonJS require() is used incorrectly or the import is misconfigured for ESM/CJS interop.
fix
Use 'const SQLiteTagSpawned = require("sqlite-tag-spawned").default;' or switch to ESM 'import'.
Upgrade
Version history
0.7.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
16 hits · last 30 days
node
10
Meta
2
OpenAI (training)
1
Resources
sqlite-tag-spawned — npm install sqlite-tag-spawned · libregistry