PostgreSQL parser for Rust that uses the actual PostgreSQL server source to parse SQL queries and return the internal PostgreSQL parse tree.
Warning! This library is in early stages of development so any APIs exposed are subject to change.
Add the following to your Cargo.toml
[dependencies]
pg_query = "0.1"
use pg_query::ast::Node;
let result = pg_query::parse("SELECT * FROM contacts");
assert!(result.is_ok());
let result = result.unwrap();
assert!(matches!(*&result[0], Node::SelectStmt(_)));
A huge thank you to Lukas Fittl for all of his amazing work creating libpg_query.