sqlparser_mysql/
lib.rs

1//! # SQL Parser for MySQL with Rust
2//!
3//! This crate provides parser that can parse SQL into an Abstract Syntax Tree.
4//!
5//! # Example parsing SQL
6//!
7//! ```
8//! use sqlparser_mysql::parser::Parser;
9//! use sqlparser_mysql::parser::ParseConfig;
10//!
11//! let config = ParseConfig::default();
12//! let sql = "SELECT a, b, 123, myfunc(b) \
13//!            FROM table_1 \
14//!            WHERE a > b AND b < 100 \
15//!            ORDER BY a DESC, b";
16//!
17//! // parse to a Statement
18//! let ast = Parser::parse(&config, sql).unwrap();
19//!
20//! println!("AST: {:?}", ast);
21//! ```
22//!
23//! # Creating SQL text from AST
24//!
25//! This crate allows users to recover the original SQL text (with comments
26//! removed, normalized whitespace and identifier capitalization), which is
27//! useful for tools that analyze and manipulate SQL.
28//!
29//! ```
30//! use sqlparser_mysql::parser::Parser;
31//! use sqlparser_mysql::parser::ParseConfig;
32//!
33//! let sql = "SELECT a FROM table_1";
34//! let config = ParseConfig::default();
35//!
36//! // parse to a Statement
37//! let ast = Parser::parse(&config, sql).unwrap();
38//!
39//! // The original SQL text can be generated from the AST
40//! assert_eq!(ast.to_string(), sql);
41//! ```
42//!
43//! [sqlparser-mysql crates.io page]: https://crates.io/crates/sqlparser-mysql
44
45#![allow(unused)]
46extern crate core;
47extern crate nom;
48#[cfg(test)]
49#[macro_use]
50extern crate pretty_assertions;
51extern crate serde;
52#[macro_use]
53extern crate serde_derive;
54
55pub use self::parser::*;
56
57pub mod base;
58pub mod das;
59pub mod dds;
60pub mod dms;
61pub mod parser;