seanlinsley / pg_query.rs

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pg_query.rs   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.

About

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

License:MIT License


Languages

Language:Rust 100.0%