postgresql_embedded 0.1.0

Embed PostgreSQL in Rust applications
docs.rs failed to build postgresql_embedded-0.1.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: postgresql_embedded-0.18.5

PostgreSQL Embedded

ci Latest version Documentation License Semantic Versioning


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

Examples

Asynchronous API

use postgresql_embedded::PostgreSQL;

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

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

    postgresql.stop().await.unwrap();
}

Synchronous API

use postgresql_embedded::blocking::PostgreSQL;

fn main() {
    let mut postgresql = PostgreSQL::default();
    postgresql.setup().unwrap();
    postgresql.start().unwrap();

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

    postgresql.stop().unwrap();
}

Information

The downloaded postgresql binaries are cached in the following directories:

  • Unix: $HOME/.theseus/postgresql
  • Windows: %USERPROFILE%\.theseus\postgresql

Feature flags

postgresql_embedded uses [feature flags] to address compile time and binary size uses.

The following features are available:

Name Description Default?
bundled Bundles the PostgreSQL archive into the resulting binary Yes
blocking Enables the blocking API; requires tokio No
tokio Enables using tokio for async No

Safety

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

License

Licensed under either of

at your option.

Notes

Uses PostgreSQL binaries from theseus-rs/postgresql-binaries.

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.