{"id":46470,"library":"sqlite-parser-cwx","title":"sqlite-parser","description":"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.","status":"active","version":"1.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/jinhuiWong/sqlite-parser","tags":["javascript","sql","sqlite","parser","syntax","ast"],"install":[{"cmd":"npm install sqlite-parser-cwx","lang":"bash","label":"npm"},{"cmd":"yarn add sqlite-parser-cwx","lang":"bash","label":"yarn"},{"cmd":"pnpm add sqlite-parser-cwx","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The package uses CommonJS by default, but ESM interop works with default import.","wrong":"const sqliteParser = require('sqlite-parser').default","symbol":"default","correct":"import sqliteParser from 'sqlite-parser'"},{"note":"Named export for stream transform parser. Available since v1.0.0.","wrong":null,"symbol":"createParser","correct":"import { createParser } from 'sqlite-parser'"},{"note":"Named export for stream stitcher. Available since v1.0.0.","wrong":null,"symbol":"createStitcher","correct":"import { createStitcher } from 'sqlite-parser'"}],"quickstart":{"code":"import sqliteParser from 'sqlite-parser';\n\n// Synchronous usage\nconst query = \"SELECT id, name FROM users WHERE age > 18;\";\ntry {\n  const ast = sqliteParser(query);\n  console.log(JSON.stringify(ast, null, 2));\n} catch (error) {\n  console.error('Parse error:', error.message);\n}\n\n// Asynchronous usage\nsqliteParser(query, (err, ast) => {\n  if (err) {\n    console.error(err);\n    return;\n  }\n  console.log(ast);\n});\n\n// Stream transform\nimport { createReadStream } from 'fs';\nimport { createParser, createStitcher } from 'sqlite-parser';\n\nconst readStream = createReadStream('./large.sql');\nconst parserTransform = createParser();\nconst stitcherTransform = createStitcher();\n\nreadStream.pipe(parserTransform).pipe(stitcherTransform).pipe(process.stdout);\n\nparserTransform.on('error', (err) => {\n  console.error(err);\n  process.exit(1);\n});","lang":"typescript","description":"Demonstrates synchronous, asynchronous, and stream-based parsing of SQLite queries with error handling."},"warnings":[{"fix":"Update calls to either use the sync return value or provide a callback.","message":"Version 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.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Review the SQLite 3 spec coverage; use a fallback parser for unsupported syntax.","message":"The 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.","severity":"gotcha","affected_versions":"*"},{"fix":"Pipe through createStitcher() or manually wrap output if you need a single JSON structure.","message":"When 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.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"search_vec":"'1.0.4':19 '3':10,57 'abstract':13 'accur':60 'activ':26 'ast':16,61,72 'asynchron':33 'built':53 'cli':43 'develop':27 'file':39 'generic':46 'global':42 'javascript':5,67 'larg':38 'latest':22 'librari':6,50 'pars':8,34 'parser':3,48,70 'provid':59 'queri':11 'releas':24 'represent':17 'spec':58 'specif':52,65 'sql':47,68 'sqlite':2,9,56,64,69 'sqlite-pars':1 'sqlite-specif':63 'stabl':23 'stream':35 'support':29 'synchron':31 'syntax':14,66,71 'tool':44 'transform':36 'tree':15 'unlik':45 'version':18","created_at":"2026-06-07T13:00:05.402279+00:00","updated_at":"2026-06-07T13:00:05.402279+00:00","problems":[{"fix":"Use const sqliteParser = require('sqlite-parser').default; or switch to ES import.","cause":"Using require('sqlite-parser') instead of require('sqlite-parser').default in CommonJS when the package is imported with a bundler that expects default export.","error":"sqliteParser is not a function"},{"fix":"Run npm install sqlite-parser and ensure the import path is correct.","cause":"Package not installed or incorrect import path.","error":"Cannot find module 'sqlite-parser'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/jinhuiWong/sqlite-parser#readme","github":"https://github.com/jinhuiWong/sqlite-parser","docs":null,"changelog":null,"pypi":null,"npm":"sqlite-parser-cwx","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}