Registry / devops / sqlite-parser-cwx

sqlite-parser-cwx

JSON →
library1.0.4jsnpmunverified

A JavaScript library that parses SQLite 3 queries into abstract syntax tree (AST) representations. Version 1.0.4 is the latest stable release, under active development. It supports both synchronous and asynchronous parsing, stream transforms for large files, and a global CLI tool. Unlike generic SQL parsers, this library is specifically built against the SQLite 3 spec, providing accurate ASTs for SQLite-specific syntax.

npm install sqlite-parser-cwx
INSTALL
IMPORT
SIG · SQLITE-PARSER-CWX
S
sqlite-parser-cwx
devopsjavascriptv1.0.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.

default
import sqliteParser from 'sqlite-parser'
const sqliteParser = require('sqlite-parser').default
The package uses CommonJS by default, but ESM interop works with default import.
createParser
import { createParser } from 'sqlite-parser'
Named export for stream transform parser. Available since v1.0.0.
createStitcher
import { createStitcher } from 'sqlite-parser'
Named export for stream stitcher. Available since v1.0.0.

Demonstrates synchronous, asynchronous, and stream-based parsing of SQLite queries with error handling.

import sqliteParser from 'sqlite-parser'; // Synchronous usage const query = "SELECT id, name FROM users WHERE age > 18;"; try { const ast = sqliteParser(query); console.log(JSON.stringify(ast, null, 2)); } catch (error) { console.error('Parse error:', error.message); } // Asynchronous usage sqliteParser(query, (err, ast) => { if (err) { console.error(err); return; } console.log(ast); }); // Stream transform import { createReadStream } from 'fs'; import { createParser, createStitcher } from 'sqlite-parser'; const readStream = createReadStream('./large.sql'); const parserTransform = createParser(); const stitcherTransform = createStitcher(); readStream.pipe(parserTransform).pipe(stitcherTransform).pipe(process.stdout); parserTransform.on('error', (err) => { console.error(err); process.exit(1); });
Debug
Known issues
breakingVersion 1.0.0 changed the API: the function now returns an AST synchronously when no callback is provided, and accepts a callback for async usage. Previously, it only supported async callbacks. Upgrade your code to handle both patterns.
fix
Update calls to either use the sync return value or provide a callback.
affects: <1.0.0
gotchaThe parser does not support all SQLite extensions (e.g., virtual table syntax, some PRAGMAs). Queries with unsupported features may throw parse errors or produce incomplete ASTs.
fix
Review the SQLite 3 spec coverage; use a fallback parser for unsupported syntax.
affects: *
gotchaWhen using the stream transform, the output is JSON strings for each statement, not a single JSON array. Use createStitcher to wrap output in a valid JSON array.
fix
Pipe through createStitcher() or manually wrap output if you need a single JSON structure.
affects: *
Errors
Common errors & fixes
sqliteParser is not a function
Using require('sqlite-parser') instead of require('sqlite-parser').default in CommonJS when the package is imported with a bundler that expects default export.
fix
Use const sqliteParser = require('sqlite-parser').default; or switch to ES import.
Cannot find module 'sqlite-parser'
Package not installed or incorrect import path.
fix
Run npm install sqlite-parser and ensure the import path is correct.
Upgrade
Version history
1.0.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
12
Resources
sqlite-parser-cwx — npm install sqlite-parser-cwx · libregistry