Registry / database / minisqlite

minisqlite

JSON →
library2.3.0jsnpmunverified

Minisqlite provides SQLite bindings for Node.js with the current stable version 2.3.0. It wraps SQLite 3.36.0, offering pull-based processing for coordinated fetching from JavaScript and support for user-defined JavaScript functions. Unlike popular alternatives like better-sqlite3 or sql.js, minisqlite emphasizes direct control over fetching and integrates custom functions seamlessly. The package is actively maintained with regular updates.

npm install minisqlite
INSTALL
IMPORT
SIG · MINISQLITE
M
minisqlite
databasejavascriptv2.3.0
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.

Database
import { Database } from 'minisqlite'
const Database = require('minisqlite').Database
Named export since v2.
Statement
import { Statement } from 'minisqlite'
import Statement from 'minisqlite'
Statement is a named export.
minisqlite
import * as minisqlite from 'minisqlite'
const minisqlite = require('minisqlite')
Namespace import for all exports.

Creates an in-memory SQLite database, executes DDL and DML statements, then queries using pull-based iteration.

import { Database } from 'minisqlite'; const db = new Database(':memory:'); db.exec('CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)'); db.exec("INSERT INTO users (name) VALUES ('Alice')"); const stmt = db.prepare('SELECT * FROM users'); for (const row of stmt.iterate()) { console.log(row); }
Debug
Known issues
breakingDatabase constructor no longer accepts options object with 'memory' flag; use ':memory:' string instead
fix
Use new Database(':memory:') instead of new Database({ memory: true }).
affects: >=2.0.0
gotchaStatement.iterate() returns a generator, not an array; requires manual iteration or spread
fix
Use for...of or Array.from() to collect rows.
affects: >=2.0.0
deprecatedThe 'each' method on Database is deprecated; use prepare() with iterate() instead
fix
Replace db.each(sql, callback) with const stmt = db.prepare(sql); for (const row of stmt.iterate()) { callback(row); }.
affects: >=2.3.0
gotchaUser-defined function callbacks run synchronously; async callbacks not supported
fix
Ensure callbacks are synchronous; avoid async/await inside custom functions.
affects: <3.0.0
breakingNode.js version <12 not supported; SQLite native addon requires N-API
fix
Upgrade Node.js to version 12 or later.
affects: >=2.0.0
Errors
Common errors & fixes
Error: Cannot find module 'minisqlite'
Package not installed or import path incorrect
fix
Run npm install minisqlite and ensure import uses named export: import { Database } from 'minisqlite'.
TypeError: db.exec is not a function
Using default import instead of named import
fix
Change import minisqlite from 'minisqlite' to import { Database } from 'minisqlite' and instantiate new Database().
Error: SQLITE_ERROR: no such table: users
Table not created before querying
fix
Execute CREATE TABLE statement before attempting to query the table.
Error: prepare requires a string argument
Passing a non-string value to prepare()
fix
Ensure the argument to db.prepare() is a string SQL query.
Upgrade
Version history
2.3.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Resources
minisqlite — npm install minisqlite · libregistry