Registry / database / bare-sqlite

bare-sqlite

JSON →
library0.1.4jsnpmunverified

SQLite bindings for the Bare runtime environment (v0.1.4). Provides synchronous database operations using a compiled C addon for performance and low memory footprint. Supports prepared statements, tagged template literal queries with LRU caching, extension loading (with security switches), foreign key constraints, and both WAL/delete journal modes. Unlike sql.js (WebAssembly) or better-sqlite3 (Node.js), bare-sqlite is designed specifically for Bare and ships with TypeScript declarations. Release cadence is irregular; breaking changes may occur before v1.0.

npm install bare-sqlite
INSTALL
IMPORT
SIG · BARE-SQLITE
B
bare-sqlite
databasejavascriptv0.1.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.

DatabaseSync
import { DatabaseSync } from 'bare-sqlite'
const DatabaseSync = require('bare-sqlite')
The module exports a named export 'DatabaseSync'; no default export exists. Use ESM or CJS destructuring.
DatabaseSync (CommonJS)
const { DatabaseSync } = require('bare-sqlite')
const db = require('bare-sqlite')
In CJS, destructure the require result to get DatabaseSync.
StatementSync
import { StatementSync } from 'bare-sqlite'
import { StatementSync } from 'bare-sqlite/stmt'
StatementSync is not directly exported; use the return type of db.prepare().
TagStore
const sql = db.createTagStore()
import { TagStore } from 'bare-sqlite'
TagStore is a class returned by createTagStore(), not exported from the package.

Creates an in-memory SQLite database, creates a table, inserts rows, iterates over results, and closes the connection.

const { DatabaseSync } = require('bare-sqlite'); const db = new DatabaseSync(':memory:'); db.exec(`CREATE TABLE books (id INTEGER PRIMARY KEY, title TEXT); INSERT INTO books (title) VALUES ('Dune'), ('Foundation');`); for (const row of db.prepare('SELECT id, title FROM books').iterate()) { console.log(row); } db.close();
Debug
Known issues
breakingPre-v1.0 breaking changes may occur.
fix
Pin to exact version and review changelog before upgrading.
affects: <1.0.0
deprecatedDatabaseSync is the stable API; older versions may have had Database with async methods.
fix
Use DatabaseSync for synchronous operation.
affects: <=0.0.x
gotchaExtension loading is disabled by default and must be enabled via allowExtension: true in options.
fix
Pass allowExtension: true during construction to enable loadExtension().
affects: >=0.1.0
gotchaThe database must be closed to release resources; otherwise open handles may cause memory leaks.
fix
Always call db.close() after use, or use a try/finally block.
affects: >=0.1.0
breakingBare runtime is required; package does not work in Node.js or browsers.
fix
Use the package only in Bare environments.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Database is not open
Attempted to operate on a database that was not opened (or already closed).
fix
Ensure db.open() is called after construction (if open: false) or before operations.
Error: SQLITE_BUSY: database is locked
Concurrent access exceeded the busy timeout (default 0).
fix
Set timeout in options (e.g., timeout: 5000) or handle concurrency externally.
TypeError: db.prepare is not a function
Importing the wrong object (e.g., using require('bare-sqlite') directly instead of destructuring DatabaseSync).
fix
Use const { DatabaseSync } = require('bare-sqlite') and instantiate with new.
Upgrade
Version history
0.1.4latest on npm
Audit
Dependencies
bare-bufferoptionalpeer dependency required by the addon for Buffer handling
Agent activity
10 hits · last 30 days
node
8
Amazon
1
OpenAI (training)
1
Resources
bare-sqlite — npm install bare-sqlite · libregistry