1 unstable release

0.10.1-alpha.0 Sep 6, 2021
0.0.1 Sep 6, 2021

#16 in #dialect

34 downloads per month
Used in 2 crates

Apache-2.0

320KB
7.5K SLoC

This is a helper crate for sqlx-models. Don't directly depend on it.


lib.rs:

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 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);

Dependencies

~46–495KB
~11K SLoC