{"library":"sqlite3-parser","title":"sqlite3-parser","type":"library","description":"A fast, pure JavaScript LALR(1) parser for SQLite SQL syntax, generated from SQLite's parse.y grammar. Version 0.7.1 ships TypeScript types, runs in Node, Bun, and browsers, and is ~32 KB gzipped. It provides improved error messages with location, expected tokens, and common mistake hints. Compared to alternatives like sql.js or node-sqlite3, it is purely a parser (no database connection) and is 2x-200x faster than other JavaScript SQL parsers (e.g., @nene/query-lang, sql-parser-cst).","language":"javascript","status":"active","last_verified":"Mon Apr 27","install":{"commands":["npm install sqlite3-parser"],"cli":null},"imports":["import { parse } from 'sqlite3-parser'","import { parseStmt } from 'sqlite3-parser'","import { parseOrThrow } from 'sqlite3-parser'","import type { ParseOk } from 'sqlite3-parser'","import type { ParseDiagnostic } from 'sqlite3-parser'"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":null,"github":"https://github.com/justjake/sqlite3-parser-js","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/sqlite3-parser","openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"import { parse, parseStmt, parseOrThrow } from 'sqlite3-parser';\n\n// Parse multiple statements\nconst multi = parse(`SELECT * FROM t1; INSERT INTO t2 VALUES (1)`);\nif (multi.status === 'ok') {\n  console.log(multi.root.cmds.length); // 2\n  console.log(multi.root.cmds[0].type); // SelectStmt\n}\n\n// Parse single statement\nconst single = parseStmt('SELECT id FROM users WHERE name = ?');\nif (single.status === 'ok') {\n  console.log(single.root.type); // SelectStmt\n}\n\n// Parse or throw\nconst stmt = parseOrThrow('UPDATE t SET x = 1');\nconsole.log(stmt.root.type); // CmdList (always contains one command)\n\n// Incremental parsing with allowTrailing\nconst result = parseStmt('SELECT 1; SELECT 2', { allowTrailing: true });\nif (result.status === 'ok') {\n  console.log(result.tail); // 9 (index where next statement starts)\n}","lang":"typescript","description":"Demonstrates parsing multiple statements, single statement, throwing on error, and incremental parsing with allowTrailing option.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}