{"id":14047,"library":"sqlite-parser","title":"SQLite 3 Query Parser","description":"The `sqlite-parser` library provides a JavaScript implementation for parsing SQLite 3 SQL queries, generating an Abstract Syntax Tree (AST) representation. It supports both synchronous and asynchronous parsing via a callback function, allowing for flexible integration into applications. Since version 1.0.0, it introduced experimental stream transform capabilities (`createParser`, `createStitcher`) designed to handle large SQL files efficiently by processing them in chunks rather than loading the entire file into memory, which helps mitigate memory limitations. The library explicitly targets the SQLite 3 specification for its parsing logic. Its latest release, v1.0.1, was published over seven years ago (as of 2026), indicating that the project is no longer actively maintained. The AST structure itself underwent significant changes in pre-1.0.0 releases, particularly regarding property casing and the representation of complex expressions like `CASE` statements and binary operations. It is compatible with Node.js environments from version 4 onwards and can also be used in browsers via a bundled script.","status":"abandoned","version":"1.0.1","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/codeschool/sqlite-parser","tags":["javascript","sql","sqlite","parser","syntax","ast"],"install":[{"cmd":"npm install sqlite-parser","lang":"bash","label":"npm"},{"cmd":"yarn add sqlite-parser","lang":"bash","label":"yarn"},{"cmd":"pnpm add sqlite-parser","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Primarily designed for CommonJS; direct ESM import might not work without a transpiler or ESM wrapper. The main export is the parser function itself.","wrong":"import sqliteParser from 'sqlite-parser';","symbol":"sqliteParser","correct":"const sqliteParser = require('sqlite-parser');"},{"note":"Used for creating a stream transform for parsing large SQL files. Available since v1.0.0. Follows CommonJS named export pattern.","wrong":"import { createParser } from 'sqlite-parser';","symbol":"createParser","correct":"const { createParser } = require('sqlite-parser');"},{"note":"Used in conjunction with `createParser` to combine streamed AST nodes into a single, valid JSON array. Available since v1.0.0. Follows CommonJS named export pattern.","wrong":"import { createStitcher } from 'sqlite-parser';","symbol":"createStitcher","correct":"const { createStitcher } = require('sqlite-parser');"}],"quickstart":{"code":"const sqliteParser = require('sqlite-parser');\nconst fs = require('fs');\nconst path = require('path');\n\nconst query = 'SELECT pants FROM laundry WHERE color = \"blue\";';\n\n// Synchronous parsing\ntry {\n  const astSync = sqliteParser(query);\n  console.log('Synchronous AST:', JSON.stringify(astSync, null, 2));\n} catch (err) {\n  console.error('Synchronous Error:', err.message);\n}\n\n// Asynchronous parsing with callback\nsqliteParser(query, function (err, astAsync) {\n  if (err) {\n    console.error('Asynchronous Error:', err.message);\n    return;\n  }\n  console.log('Asynchronous AST:', JSON.stringify(astAsync, null, 2));\n});\n\n// Example for stream parsing (requires a dummy file)\nconst largeSqlFile = path.join(__dirname, 'large-input.sql');\nfs.writeFileSync(largeSqlFile, 'CREATE TABLE users (id INT, name TEXT);\\nINSERT INTO users VALUES (1, \\'Alice\\');');\n\nconst parserTransform = sqliteParser.createParser();\nconst singleNodeTransform = sqliteParser.createStitcher();\nconst readStream = fs.createReadStream(largeSqlFile);\n\nconsole.log('\\n--- Stream Parsing Output ---');\nreadStream.pipe(parserTransform);\nparserTransform.pipe(singleNodeTransform);\nsingleNodeTransform.pipe(process.stdout);\n\nparserTransform.on('error', function (err) {\n  console.error('\\nStream Parser Error:', err.message);\n  process.exit(1);\n});\n\nsingleNodeTransform.on('finish', function () {\n  console.log('\\n--- Stream Parsing Finished ---');\n  fs.unlinkSync(largeSqlFile); // Clean up dummy file\n});\n","lang":"javascript","description":"This quickstart demonstrates both synchronous and asynchronous parsing of a single SQLite query using the `sqliteParser` function. It also includes an example of how to use the `createParser` and `createStitcher` stream transforms for parsing large SQL files, writing the resulting AST to stdout."},"warnings":[{"fix":"Update consumers of the AST to expect and handle lowercase property values, performing case-insensitive checks if compatibility with older ASTs is required.","message":"All named values for properties such as `variant`, `format`, and `type` in the AST are now always lowercase, even if uppercase in the input SQL (e.g., `NATURAL JOIN` becomes `natural join`).","severity":"breaking","affected_versions":">=1.0.0-rc2"},{"fix":"Review and refactor code that processes `CASE` expressions in the AST to conform to the new structure, especially regarding `variant` types and property names.","message":"The AST format for `CASE` expressions has significantly changed. The outer expression is now `variant: 'case'`, and internal `when` and `else` variants have specific `condition` and `consequent` properties.","severity":"breaking","affected_versions":">=1.0.0-rc2"},{"fix":"Thoroughly test existing SQL queries to verify the generated ASTs and adjust any logic that relies on a specific parse tree order for complex binary expressions.","message":"The parsing order for binary expressions was changed, which may result in different AST structures for queries containing multiple chained binary expressions (e.g., `WHERE x != 2 OR x == 3 AND y > 5`).","severity":"breaking","affected_versions":">=0.15.0-beta"},{"fix":"Update AST traversal or processing logic to correctly identify and handle `NOT NULL` as a binary expression rather than a unary one.","message":"Expressions like `x NOT NULL` which were previously treated as unary expressions are now considered binary expressions in the AST.","severity":"breaking","affected_versions":">=0.15.0-beta"},{"fix":"Ensure you are using the correct browserified (unminified) bundle if deploying to browser environments. Avoid relying on custom minification of the `dist/sqlite-parser.js` file if you encounter this error.","message":"Running the uglified bundle (`dist/sqlite-parser.js`) in the browser could lead to a `RangeError: Maximum call stack size exceeded`. As a result, the minification step was skipped, and only the browserified bundle is published.","severity":"gotcha","affected_versions":">=1.0.0-rc3"},{"fix":"Consider the long-term viability and security implications when adopting this library. Evaluate alternative, actively maintained SQLite parsers if active development and support are critical requirements.","message":"This project appears to be abandoned, with its last release (v1.0.1) over 7 years ago. No further updates, bug fixes, or security patches are expected.","severity":"gotcha","affected_versions":">=1.0.1"}],"env_vars":null,"search_vec":"'1.0.0':46,123 '2026':104 '3':2,17,86 '4':149 'abstract':22 'activ':112 'ago':101 'allow':38 'also':153 'applic':43 'ast':25,115,167 'asynchron':32 'binari':139 'browser':157 'bundl':160 'callback':36 'capabl':52 'case':128,136 'chang':120 'chunk':66 'compat':143 'complex':133 'createpars':53 'createstitch':54 'design':55 'effici':61 'entir':71 'environ':146 'experiment':49 'explicit':82 'express':134 'file':60,72 'flexibl':40 'function':37 'generat':20 'handl':57 'help':76 'implement':13 'indic':105 'integr':41 'introduc':48 'javascript':12,162 'larg':58 'latest':93 'librari':9,81 'like':135 'limit':79 'load':69 'logic':91 'longer':111 'maintain':113 'memori':74,78 'mitig':77 'node.js':145 'onward':150 'oper':140 'pars':15,33,90 'parser':4,8,165 'particular':125 'pre':122 'process':63 'project':108 'properti':127 'provid':10 'publish':97 'queri':3,19 'rather':67 'regard':126 'releas':94,124 'represent':26,131 'script':161 'seven':99 'signific':119 'sinc':44 'specif':87 'sql':18,59,163 'sqlite':1,7,16,85,164 'sqlite-pars':6 'statement':137 'stream':50 'structur':116 'support':28 'synchron':30 'syntax':23,166 'target':83 'transform':51 'tree':24 'underw':118 'use':155 'v1.0.1':95 'version':45,148 'via':34,158 'year':100","created_at":"2026-04-20T01:57:39.199742+00:00","updated_at":"2026-04-20T01:57:39.199742+00:00","problems":[{"fix":"Do not use the minified `dist/sqlite-parser.js` directly in a browser environment; use the provided browserified bundle, which skips minification to avoid this issue (as of v1.0.0-rc3).","cause":"Occurs when attempting to run the uglified browser bundle due to recursive parsing logic.","error":"RangeError: Maximum call stack size exceeded"},{"fix":"Ensure you are using a version >= 0.14.2. If on an older version, manually verify `dist/sqlite-parser.min.js` exists or update to a newer, stable release.","cause":"In versions prior to v0.14.2, the minified bundle targeted by `package.json`'s `main` property was sometimes missing from the `dist/` folder after release tasks.","error":"Error: Cannot find module 'sqlite-parser' or parser not working after npm install"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/codeschool/sqlite-parser","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/sqlite-parser","openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization","database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}