{"id":43780,"library":"rw-sql-parser","title":"rw-sql-parser","description":"A lexer and parser for basic SQL SELECT queries, written in JavaScript using JISON. This package is a fork of Forward's SQL Parser, with added support for hyphens in literals. It tokenizes SQL strings into a stream of tokens and parses them into a Select object with properties for where, group, order, and limit. Version 1.0.1 is the current stable release. It only supports basic SELECT statements and lacks full SQL coverage. The package is primarily intended for Node.js environments and requires CoffeeScript for building from source.","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/resource-watch/sql-parser","tags":["javascript"],"install":[{"cmd":"npm install rw-sql-parser","lang":"bash","label":"npm"},{"cmd":"yarn add rw-sql-parser","lang":"bash","label":"yarn"},{"cmd":"pnpm add rw-sql-parser","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The lexer is exported as a named export.","symbol":"lexer","correct":"import { lexer } from 'rw-sql-parser'"},{"note":"The parser is exported as a named export.","symbol":"parser","correct":"import { parser } from 'rw-sql-parser'"},{"note":"Select is a node type; available as named export if using lib/nodes.","symbol":"Select","correct":"import { Select } from 'rw-sql-parser'"}],"quickstart":{"code":"import { lexer, parser } from 'rw-sql-parser';\n\nconst sql = \"select * from my_table where foo = 'bar'\";\nconst tokens = lexer.tokenize(sql);\nconsole.log(tokens);\n// [['SELECT','select',1],['STAR','*',1],['FROM','from',1],['LITERAL','my_table',1],['WHERE','where',1],['LITERAL','foo',1],['EQ','=',1],['STRING','bar',1]]\n\nconst ast = parser.parse(tokens);\nconsole.log(ast.toString());\n// SELECT *\n//   FROM `my_table`\n//   WHERE `foo` = 'bar'","lang":"typescript","description":"Shows lexer tokenization and parser AST generation for a basic SELECT query."},"warnings":[{"fix":"Use a more complete SQL parser like `node-sql-parser` for full SQL support.","message":"Only basic SELECT queries are supported. Complex joins, subqueries, INSERT, UPDATE, DELETE are not implemented.","severity":"gotcha","affected_versions":"<=1.0.1"},{"fix":"Access token type via index 0, value via index 1.","message":"The token format is an array of [NAME, value, lineNumber] tailored for JISON, not standard JavaScript objects.","severity":"gotcha","affected_versions":"<=1.0.1"},{"fix":"Run `npm install && cake build` if installing from source.","message":"The package requires CoffeeScript for building from source. npm install alone may not work without cake build.","severity":"gotcha","affected_versions":"<=1.0.1"}],"env_vars":null,"search_vec":"'1.0.1':61 'ad':30 'basic':10,70 'build':90 'coffeescript':88 'coverag':77 'current':64 'environ':85 'fork':23 'forward':25 'full':75 'group':56 'hyphen':33 'intend':82 'javascript':16,93 'jison':18 'lack':74 'lexer':6 'limit':59 'liter':35 'node.js':84 'object':51 'order':57 'packag':20,79 'pars':46 'parser':4,8,28 'primarili':81 'properti':53 'queri':13 'releas':66 'requir':87 'rw':2 'rw-sql-parser':1 'select':12,50,71 'sourc':92 'sql':3,11,27,38,76 'stabl':65 'statement':72 'stream':42 'string':39 'support':31,69 'token':37,44 'use':17 'version':60 'written':14","created_at":"2026-06-05T17:01:26.560619+00:00","updated_at":"2026-06-05T17:01:26.560619+00:00","problems":[{"fix":"Run `npm install rw-sql-parser` and ensure it's in node_modules.","cause":"Package not installed or npm install failed.","error":"Error: Cannot find module 'rw-sql-parser'"},{"fix":"Use `import { lexer } from 'rw-sql-parser';`","cause":"Incorrect import; lexer is named, not default.","error":"TypeError: lexer.tokenize is not a function"},{"fix":"Restrict to basic SELECT with WHERE, GROUP BY, ORDER BY, LIMIT.","cause":"Query contains unsupported SQL syntax (e.g., JOIN, subquery).","error":"SyntaxError: Unexpected token"}],"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/resource-watch/sql-parser#readme","github":"ssh://git@github.com/resource-watch/sql-parser","docs":null,"changelog":null,"pypi":null,"npm":"rw-sql-parser","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}