Crate sql_ast[][src]

Expand description

SQL Parser for Rust

Example code:

This crate provides an ANSI:SQL 2011 lexer and parser that can parse SQL into an Abstract Syntax Tree (AST).

use sql_ast::dialect::GenericDialect;
use sql_ast::parser::Parser;

let dialect = GenericDialect {}; // or AnsiDialect

let sql = "SELECT a, b, 123, myfunc(b) \
           FROM table_1 \
           WHERE a > b AND b < 100 \
           ORDER BY a DESC, b";

let ast = Parser::parse_sql(&dialect, sql.to_string()).unwrap();

println!("AST: {:?}", ast);


SQL Abstract Syntax Tree (AST) types

SQL Parser

SQL Tokenizer


Primitive SQL values such as number and string