9 releases

0.8.0 Apr 6, 2024
0.7.5 Jun 29, 2021
0.7.4 Dec 5, 2020
0.7.1 Nov 10, 2020
0.5.1-alpha-1 Jan 6, 2020

#704 in Database interfaces

Download history 43/week @ 2024-07-26 5/week @ 2024-08-02 1/week @ 2024-09-20 16/week @ 2024-09-27 2/week @ 2024-10-04

739 downloads per month

Apache-2.0

185KB
4.5K SLoC

Extensible SQL Lexer and Parser for Rust

License Version Build Status

A lean SQL abstract syntax tree and parser

Forked from https://github.com/ballista-compute/sqlparser-rs


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

Dependencies

~45–300KB