百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
P

pg_parse

> 数据库
开源

PostgreSQL 解析器用于 Rust,它使用实际的 PostgreSQL 服务器源代码来解析 SQL 查询,并返回内部的 PostgreSQL 解析树。

100 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

PostgreSQL 解析器用于 Rust,它使用实际的 PostgreSQL 服务器源代码来解析 SQL 查询,并返回内部的 PostgreSQL 解析树。

pg_parse   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.

Getting started

Add the following to your Cargo.toml

toml
[dependencies]
pg_parse = "0.15"

Example: Parsing a query

rust
use pg_parse::ast::Node;

let result = pg_parse::parse("SELECT * FROM contacts");
assert!(result.is_ok());
let result = result.unwrap();
assert!(matches!(*&result[0], Node::SelectStmt(_)));

// We can also convert back to a string, if the `str` feature is enabled (enabled by default).
#[cfg(feature = "str")]
assert_eq!(result[0].to_string(), "SELECT * FROM contacts");

What's the difference between pg_parse and pg_query.rs?

The pganalyze organization maintains the official implementation: pg_query.rs. This closely resembles the name of the C library also published by the team (libpg_query). This implementation uses 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 and serde_json being the only required runtime dependencies.

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.

Credits

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

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rustpostgresqlrust

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类数据库
定价开源

> 相关工具

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库