{"library":"sql-parser","title":"SQL Parser","type":"library","description":"The `sql-parser` package provides a JavaScript-based lexer and parser specifically designed for SQL syntax. As of version 0.5.0, it is primarily capable of tokenizing and parsing fairly basic `SELECT` queries, offering functionalities like `WHERE`, `GROUP BY`, `ORDER BY`, and `LIMIT` clause parsing. The lexer outputs tokens in a format compatible with JISON, which the parser then consumes to produce a `Select` object. A notable feature is the ability to reconstruct a well-formatted SQL string from the parsed object via its `.toString()` method. The project appears to be in a largely unmaintained state, with no indication of active development towards comprehensive SQL support or regular releases since its initial limited scope. Its implementation borrowed heavily from CoffeeScript project boilerplate, suggesting an older codebase that predates modern JavaScript module patterns and extensive TypeScript adoption.","language":"javascript","status":"abandoned","last_verified":"Sun Apr 19","install":{"commands":["npm install sql-parser"],"cli":null},"imports":["const { lexer } = require('sql-parser');","const { parser } = require('sql-parser');","const Lexer = require('sql-parser').Lexer;"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":null,"github":"https://github.com/forward/sql-parser","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/sql-parser","openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"const { lexer, parser } = require('sql-parser');\n\nconst sqlQuery = \"select id, name from users where age > 18 order by name asc limit 10\";\n\nconsole.log('Original SQL:', sqlQuery);\n\n// Tokenize the SQL query\nconst tokens = lexer.tokenize(sqlQuery);\nconsole.log('Tokens:', JSON.stringify(tokens, null, 2));\n\n// Parse the tokens into a Select object (AST-like structure)\ntry {\n  const selectObject = parser.parse(tokens);\n  console.log('Parsed Object (simplified):', selectObject);\n\n  // Convert the parsed object back to a formatted SQL string\n  const formattedSql = selectObject.toString();\n  console.log('Formatted SQL from object:\\n', formattedSql);\n} catch (e) {\n  console.error('Parsing error:', e.message);\n}","lang":"javascript","description":"Demonstrates tokenizing a basic SELECT query, parsing it into a 'Select' object, and then re-generating a formatted SQL string.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}