Registry / database / sqlite-executor

sqlite-executor

JSON →
library4.0.6jsnpmunverified

A lightweight, zero-dependency SQLite wrapper for Node.js that communicates with the sqlite3 CLI via stdin/stdout — no native addons, no node-gyp, no ABI headaches. Version 4.0.6 requires Node.js >= 18 and the sqlite3 CLI executable on the system. Key differentiators: pure JavaScript, no compilation needed; long-lived single sqlite3 process for the entire app lifecycle; Promise-based API with execute(), query(), and stream() methods; automatic transaction support with concurrent caller serialization; dedicated reader pool for concurrent read queries; per-statement timeout with process-level failure recovery; auto-restart on crash; runtime metrics (QPS, avg query time, timeout count, restarts). Includes full TypeScript types and dual ESM/CommonJS module support.

database
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.

The default export is not available; must use named import.

import { SQLiteExecutor } from 'sqlite-executor'

CommonJS requires destructured require.

const { SQLiteExecutor } = require('sqlite-executor')

The class is named 'Metrics', not 'Metric'.

import { Metrics } from 'sqlite-executor'

Logger is a TypeScript interface, not a value. Use type import for type-only usage.

import type { Logger } from 'sqlite-executor'

Options interface is not exported as a value; only available as a type.

import type { SQLiteExecutorOptions } from 'sqlite-executor'

Creates an in-memory SQLite database, creates a table, inserts two rows, queries them, and closes the connection.

import { SQLiteExecutor } from 'sqlite-executor'; const db = new SQLiteExecutor({ database: ':memory:' }); await db.execute( `CREATE TABLE IF NOT EXISTS users ( id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT )` ); await db.execute('INSERT INTO users (name) VALUES (?)', ['Alice']); await db.execute('INSERT INTO users (name) VALUES (?)', ['Bob']); const rows = await db.query('SELECT * FROM users ORDER BY id ASC'); console.log(rows); // [ { id: 1, name: 'Alice' }, { id: 2, name: 'Bob' } ] await db.close();
Debug
Known footguns
breakingMinimum Node.js version changed to 18 in v4.0.0
breakingAPI changed from callback-based to Promise-based in v3.0.0
breakingDefault export removed in v3.0.0
gotchasqlite3 CLI must be installed and available in PATH
gotchaReader pool (poolSize > 0) only works with file databases, not :memory:
gotchaTransactions serialize concurrent callers; long transactions block other operations
deprecatedCallback-style methods (e.g., db.all(), db.run()) removed in v3.0.0
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
10 hits · last 30 days
gptbot
3
mj12bot
1
ahrefsbot
1
Resources