Registry / database / qh-flora-sql-parser

qh-flora-sql-parser

JSON →
library0.10.1jsnpmunverified

Flora SQL Parser is a JavaScript library for parsing SQL SELECT statements into abstract syntax trees (AST) and converting ASTs back to SQL. The current stable version is 0.10.1, released intermittently with no fixed cadence. It is based on the SQL parser from Alibaba's nquery module and focuses on SELECT statements, with limited support for other DML statements. It supports ANSI SQL and requires Node.js >= 6. Unlike more comprehensive parsers like sqlite-parser or node-sql-parser, it is lighter but with narrower scope.

npm install qh-flora-sql-parser
INSTALL
IMPORT
SIG · QH-FLORA-SQL-PARSE
Q
qh-flora-sql-parser
databasejavascriptv0.10.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Parser
import { Parser } from 'flora-sql-parser';
const Parser = require('flora-sql-parser').Parser;
Library supports both ESM and CJS; but ESM is preferred for modern projects.
util.astToSQL
import { util } from 'flora-sql-parser'; const astToSQL = util.astToSQL;
const { astToSQL } = require('flora-sql-parser').util;
Alternative pattern: import { astToSQL } from 'flora-sql-parser/dist/astToSQL'; but direct import from util is simpler.
default import
import floraSQLParser from 'flora-sql-parser';
const floraSQLParser = require('flora-sql-parser');
No default export; you must destructure.

Parses a SELECT SQL statement into an AST and converts it back to SQL, demonstrating round-trip parsing.

import { Parser, util } from 'flora-sql-parser'; const parser = new Parser(); const sql = 'SELECT id, name FROM users WHERE age > 18'; const ast = parser.parse(sql); console.log('AST:', JSON.stringify(ast, null, 2)); const sqlBack = util.astToSQL(ast); console.log('SQL back:', sqlBack);
Debug
Known issues
breakingDoes not support INSERT, UPDATE, DELETE statements — only SELECT.
fix
Use another library (e.g., node-sql-parser) for full DML support.
affects: >=0.0.0
gotchaGenerated SQL is ANSI SQL compliant. MySQL requires SET SESSION sql_mode = 'ANSI' to avoid errors.
fix
Set MySQL sql_mode to 'ANSI' before executing generated queries.
affects: >=0.0.0
deprecatedThe GitHub repository URL has changed from godmodelabs to qing-hai. Old links may break.
fix
Use https://github.com/qing-hai/flora-sql-parser
affects: >=0.10.0
gotchaParser.parse() throws on invalid SQL; no graceful error handling.
fix
Wrap parse() in try-catch.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: Parser is not a constructor
Using default import when only named export exists.
fix
Use import { Parser } from 'flora-sql-parser' or const { Parser } = require('flora-sql-parser').
SyntaxError: Unexpected token at position X
Non-SELECT SQL or malformed query.
fix
Ensure input is a valid SELECT statement. For other DML, use a different parser.
Error: Can't find module 'flora-sql-parser'
Package not installed or incorrect import path.
fix
Run npm install flora-sql-parser and verify import path.
Upgrade
Version history
0.10.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
8
Resources
qh-flora-sql-parser — npm install qh-flora-sql-parser · libregistry