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

postgresql-embedded

> 数据库
开源

嵌入 PostgreSQL 数据库

388 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

嵌入 PostgreSQL 数据库

PostgreSQL Embedded

Install and run a PostgreSQL database locally on Linux, MacOS or Windows. PostgreSQL can be bundled with your application, or downloaded on demand.

This library provides an embedded-like experience for PostgreSQL similar to what you would have with SQLite. This is accomplished by downloading and installing PostgreSQL during runtime. There is also a "bundled" feature that when enabled, will download the PostgreSQL installation archive at compile time, include it in your binary and install from the binary version at runtime. In either case, PostgreSQL will run in a separate process space.

Features

  • installing and running PostgreSQL
  • running PostgreSQL on ephemeral ports
  • Unix socket support
  • async and blocking API
  • bundling the PostgreSQL archive in an executable
  • semantic version resolution
  • ability to configure PostgreSQL startup options
  • settings builder for fluent configuration
  • URL based configuration
  • choice of native-tls or rustls with AWS-LC or Ring
  • support for installing PostgreSQL extensions

Getting Started

Example

rust
use postgresql_embedded::{PostgreSQL, Result};

#[tokio::main]
async fn main() -> Result {
    let mut postgresql = PostgreSQL::default();
    postgresql.setup().await?;
    postgresql.start().await?;

    let database_name = "test";
    postgresql.create_database(database_name).await?;
    postgresql.database_exists(database_name).await?;
    postgresql.drop_database(database_name).await?;

    postgresql.stop().await
}

Notes

Supports using PostgreSQL binaries from:

  • theseus-rs/postgresql-binaries (default)
  • zonkyio/embedded-postgres-binaries

Safety

These crates use #![forbid(unsafe_code)] to ensure everything is implemented in 100% safe Rust.

License

Licensed under either of

  • Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
  • MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)

at your option.

PostgreSQL is covered under The PostgreSQL License.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Prior Art

Projects that inspired this one:

  • zonkyio/embedded-postgres-binaries
  • faokunega/pg-embed

Issues· 0 开放

查看全部 Issues在 GitHub 打开

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

> 标签

Rustbundledatabaseembeddedinstall

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

> 工具信息

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

> 相关工具

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