{"library":"sqlite-parser","title":"SQLite 3 Query Parser","type":"library","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.","language":"javascript","status":"abandoned","last_verified":"Sun Apr 19","install":{"commands":["npm install sqlite-parser"],"cli":null},"imports":["const sqliteParser = require('sqlite-parser');","const { createParser } = require('sqlite-parser');","const { createStitcher } = require('sqlite-parser');"],"auth":{"required":false,"env_vars":[]},"links":{"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},"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}