pg_parse

PostgreSQL parser for Rust that uses the actual PostgreSQL server source to parse SQL queries and return the internal PostgreSQL parse tree.
What's the difference between pg_parse vs pg_query.rs?
The pganalyze
organization will maintain the official implementation called pg_query.rs
. This
closely resembles the name of the C library also published by the team (libpg_query
). This implementation will use the protobuf
interface introduced with version 13 of libpg_query
.
This library similarly consumes libpg_query
however utilizes the older JSON interface to manage parsing. The intention of this library
is to maintain a dependency "light" implementation with serde
being the only required runtime dependency. While this was originally called
pg_query.rs
it makes sense to decouple itself from the official naming convention and go on it's own. Hence pg_parse
.
So which one should you use? You probably want to use the official pg_query.rs
library as that will continue to be
kept closely up to date with libpg_query
updates. This library will continue to be maintained however may not be as up
to date as the official implementation.
Getting started
Add the following to your Cargo.toml
[]
= "0.7"
Example: Parsing a query
use Node;
let result = parse;
assert!;
let result = result.unwrap;
assert!;
Credits
A huge thank you to Lukas Fittl for all of his amazing work creating libpg_query.