Expand description
SQL Parser for Rust
This crate provides an ANSI:SQL 2011 lexer and parser that can parse SQL
into an Abstract Syntax Tree (AST). See the sqlparser crates.io page
for more information.
For more information:
- Parser::parse_sqland- Parser::newfor the Parsing API
- astfor the AST structure
- Dialectfor supported SQL dialects
Example
use sqlparser::dialect::GenericDialect;
use sqlparser::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).unwrap();
println!("AST: {:?}", ast);Modules
- SQL Abstract Syntax Tree (AST) types
- This module defines
- SQL Parser
- SQL Tokenizer