🚀 Socket Launch Week 🚀 Day 5: Introducing Socket Fix.Learn More
Socket
Sign inDemoInstall
Socket

flora-sql-parser

Package Overview
Dependencies
Maintainers
3
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flora-sql-parser

Parse SQL (select) statements into abstract syntax tree (AST) and convert ASTs back to SQL.

0.6.0
Source
npm
Version published
Weekly downloads
908
171.04%
Maintainers
3
Weekly downloads
 
Created
Source

Flora SQL Parser

Build Status NPM version Dependencies

Parse simple SQL statements into an abstract syntax tree (AST) and convert it back to SQL.

Usage

Create AST for SQL statement:

var Parser = require('flora-sql-parser').Parser;
var parser = new Parser();
var ast = parser.parse('SELECT * FROM t');

console.log(ast);

Convert AST back to SQL:

var Parser = require('flora-sql-parser').Parser;
var ast = (new Parser()).parse('SELECT * FROM t');
var 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

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

Keywords

sql

FAQs

Package last updated on 15 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts