Registry / database / mini-sql

mini-sql

JSON →
library0.22.3jsnpmunverified

A minimal SQL interpreter written in JavaScript, using the jiwson parser generator for ES6 compatibility. Version 0.22.3 is the current stable release; the package is updated infrequently. It provides a simple interface to parse and execute basic SQL statements like SELECT, INSERT, UPDATE, and DELETE. Unlike full-fledged databases or query builders, mini-sql is lightweight and works purely in-memory, making it suitable for educational purposes or small-scale tooling where a full SQL engine is overkill.

npm install mini-sql
INSTALL
IMPORT
SIG · MINI-SQL
M
mini-sql
databasejavascriptv0.22.3
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 parser from 'mini-sql'
const parser = require('mini-sql')
Package is ESM-only and ships default export
parse
import { parse } from 'mini-sql'
import parser from 'mini-sql'; parser.parse()
Named export 'parse' also available, but default export is the parser instance.
Parser
import { Parser } from 'mini-sql'
import parser from 'mini-sql'; new parser()
The class constructor is exported as 'Parser'.

Shows how to import the default parser, parse a SELECT query, and handle parse errors.

import parser from 'mini-sql'; const sql = 'SELECT name, age FROM users WHERE age > 18'; try { const result = parser.parse(sql); console.log(result); } catch (err) { console.error('Parse error:', err.message); }
Debug
Known issues
deprecatedThe 'parse' function is deprecated and will be removed in next major version. Use 'parser.parse()' instead.
fix
Use the default import and call parser.parse(sql)
affects: >=0.21.0
gotchaMini-sql does not support JOINs or subqueries. Attempting to parse such SQL throws a parse error.
fix
Only use simple SELECT, INSERT, UPDATE, DELETE without joins or subqueries.
affects: >=0.1.0
breakingIn version 0.20.0, the API changed from callback-based to sync return values. Older code expecting callbacks will break.
fix
Use synchronous return: const result = parser.parse(sql) instead of parser.parse(sql, callback)
affects: >=0.20.0
Errors
Common errors & fixes
Error: Parse error on line 1: Unexpected token 'JOIN'
JOIN statements are not supported by mini-sql parser.
fix
Rewrite query without JOIN, or use a different SQL engine.
TypeError: parser.parse is not a function
Using incorrect import style (CommonJS require) in ESM environment.
fix
Use import parser from 'mini-sql' instead of require('mini-sql')
ReferenceError: sqlite3 is not defined
Confusion with sqlite3 package; mini-sql is a parser, not a database driver.
fix
Do not use mini-sql with sqlite3. Use better-sqlite3 or sql.js for actual database operations.
Upgrade
Version history
0.22.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
mini-sql — npm install mini-sql · libregistry