All Projects → florajs → sql-parser

florajs / sql-parser

Licence: GPL-2.0 license
Parse SQL (select) statements into abstract syntax tree (AST) and convert ASTs back to SQL.

Programming Languages

javascript
184084 projects - #8 most used programming language
PEG.js
56 projects

Projects that are alternatives of or similar to sql-parser

awesome-ruby-ast
A list of awesome tools and libraries which deals with ASTs in Ruby
Stars: ✭ 24 (-89.57%)
Mutual labels:  ast
macro-visit
A macro-based generic visitor generator
Stars: ✭ 23 (-90%)
Mutual labels:  ast
nast
A block-based intermediate representation for document-like content.
Stars: ✭ 35 (-84.78%)
Mutual labels:  ast
gox
JSX for Go
Stars: ✭ 165 (-28.26%)
Mutual labels:  ast
deco
Minimalist Function Decorators for Elixir
Stars: ✭ 21 (-90.87%)
Mutual labels:  ast
open-fortran-parser-xml
XML output generator for Open Fortran Parser, and Python wrapper for it.
Stars: ✭ 21 (-90.87%)
Mutual labels:  ast
sast
Parse CSS, Sass, SCSS, and Less into a unist syntax tree
Stars: ✭ 51 (-77.83%)
Mutual labels:  ast
codeparser
Parse Wolfram Language source code as abstract syntax trees (ASTs) or concrete syntax trees (CSTs)
Stars: ✭ 84 (-63.48%)
Mutual labels:  ast
TypeScriptAST
.NET port of Microsoft's TypeScript parser for simple AST manipulation
Stars: ✭ 37 (-83.91%)
Mutual labels:  ast
language-rust
Parser and pretty-printer for the Rust language
Stars: ✭ 78 (-66.09%)
Mutual labels:  ast
rehype-dom
HTML processor to parse and compile with browser APIs, powered by plugins
Stars: ✭ 20 (-91.3%)
Mutual labels:  ast
BBob
⚡️Blazing-fast js-bbcode-parser, bbcode js, that transforms and parses to AST with plugin support in pure javascript, no dependencies
Stars: ✭ 133 (-42.17%)
Mutual labels:  ast
lilt
LILT: noun, A characteristic rising and falling of the voice when speaking; a pleasant gentle accent.
Stars: ✭ 18 (-92.17%)
Mutual labels:  ast
venusscript
A dynamic, interpreted, scripting language written in Java.
Stars: ✭ 17 (-92.61%)
Mutual labels:  ast
vscode-ast
Show JavaScript / TypeScript Abstract Syntax Tree
Stars: ✭ 34 (-85.22%)
Mutual labels:  ast
java-ast
Java Parser for JavaScript/TypeScript (based on antlr4ts)
Stars: ✭ 58 (-74.78%)
Mutual labels:  ast
subpy
Python subsets
Stars: ✭ 41 (-82.17%)
Mutual labels:  ast
MarkdownSyntax
☄️ A Type-safe Markdown parser in Swift.
Stars: ✭ 65 (-71.74%)
Mutual labels:  ast
rector-doctrine
Rector upgrades rules for Doctrine
Stars: ✭ 37 (-83.91%)
Mutual labels:  ast
snapdragon-util
Utilities for the snapdragon parser/compiler.
Stars: ✭ 17 (-92.61%)
Mutual labels:  ast

@florajs/sql-parser

NPM version NPM downloads

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

Usage

Create AST for SQL statement

const { Parser } = require('@florajs/sql-parser');
const parser = new Parser();
const ast = parser.parse('SELECT * FROM t');

console.log(ast);

Convert AST back to SQL

const { Parser } = require('@florajs/sql-parser');
const ast = (new Parser()).parse('SELECT * FROM t');
const toSQL = require('@florajs/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

GPL-2.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].