Expand description
SQL Parser and Formatter for Rust
Example code, see more on Github:
use sqlparse::{FormatOption, Formatter};
let sql = "SELECT a, b, 123, myfunc(b) \
FROM table_1 \
WHERE a > b AND b < 100 \
ORDER BY a DESC";
let mut f = Formatter::default();
let mut formatter = FormatOption::default();
formatter.reindent = true;
formatter.reindent_aligned = true;
let formatted_sql = f.format(sql, &mut formatter);
println!("{}", formatted_sql);
Output:
SELECT a,
b,
123,
myfunc(b)
FROM table_1
WHERE a > b
AND b < 100
ORDER BY a DESC
Structs
sql format options
format sql with multiple options
parse sql
parsed sql token
grouped tokens
Enums
Functions
format sql to string, only for test
parse sql into grouped TokenList. only for test
parse sql into tokens, only for test
parse multiple sqls into tokens, only for test
parse sql into grouped tokens, only for test