pg_query 0.1.1

PostgreSQL parser that uses the actual PostgreSQL server source to parse SQL queries and return the internal PostgreSQL parse tree.
Documentation

pg_query   Build Status Latest Version Docs Badge

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.

Getting started

Add the following to your Cargo.toml

[dependencies]
pg_query = "0.1"

Example: Parsing a query

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

Credits

A huge thank you to Lukas Fittl for all of his amazing work creating libpg_query.