Parse SQL (select) statements into abstract syntax tree (AST) and convert ASTs back to SQL.
npm install qh-flora-sql-parserFlora SQL Parser
================



Parse simple SQL statements into an abstract syntax tree (AST) and convert it back to SQL.
Usage
-----
#### Create AST for SQL statement:
``javascript
`
const Parser = require('flora-sql-parser').Parser;
const parser = new Parser();
const ast = parser.parse('SELECT * FROM t');
console.log(ast);
`
#### Convert AST back to SQL:
javascript
`
const Parser = require('flora-sql-parser').Parser;
const ast = (new Parser()).parse('SELECT * FROM t');
const toSQL = require('flora-sql-parser').util.astToSQL;
console.log(toSQL(ast));
`
The generated SQL is ANSI SQL compliant. To run those queries on MySQL, make sure you set correct SQL mode
sql
``
SET SESSION sql_mode = 'ANSI';
before running any query.
Acknowledgement
--------------
This project is based on the SQL parser extracted from Alibaba's nquery module.
License
-------
MIT