Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/theseus-rs/postgresql-embedded
Embed PostgreSQL database
https://github.com/theseus-rs/postgresql-embedded
bundle database embedded install installer postgres postgresql rust
Last synced: 4 days ago
JSON representation
Embed PostgreSQL database
- Host: GitHub
- URL: https://github.com/theseus-rs/postgresql-embedded
- Owner: theseus-rs
- License: apache-2.0
- Created: 2024-02-05T20:04:41.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-11-29T19:07:57.000Z (29 days ago)
- Last Synced: 2024-12-18T01:03:08.510Z (11 days ago)
- Topics: bundle, database, embedded, install, installer, postgres, postgresql, rust
- Language: Rust
- Homepage:
- Size: 3.56 MB
- Stars: 88
- Watchers: 0
- Forks: 14
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE-APACHE
- Security: SECURITY.md
Awesome Lists containing this project
README
# PostgreSQL Embedded
[![ci](https://github.com/theseus-rs/postgresql-embedded/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/theseus-rs/postgresql-embedded/actions/workflows/ci.yml)
[![Documentation](https://docs.rs/postgresql_embedded/badge.svg)](https://docs.rs/postgresql_embedded)
[![Code Coverage](https://codecov.io/gh/theseus-rs/postgresql-embedded/branch/main/graph/badge.svg)](https://codecov.io/gh/theseus-rs/postgresql-embedded)
[![Benchmarks](https://img.shields.io/badge/%F0%9F%90%B0_bencher-enabled-6ec241)](https://bencher.dev/perf/theseus-rs-postgresql-embedded)
[![Latest version](https://img.shields.io/crates/v/postgresql_embedded.svg)](https://crates.io/crates/postgresql_embedded)
[![License](https://img.shields.io/crates/l/postgresql_embedded)](https://github.com/theseus-rs/postgresql-embedded#license)
[![Semantic Versioning](https://img.shields.io/badge/%E2%9A%99%EF%B8%8F_SemVer-2.0.0-blue)](https://semver.org/spec/v2.0.0.html)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
- async and blocking API
- bundling the PostgreSQL archive in an executable
- semantic version resolution
- support for custom PostgreSQL archives / binaries
- ability to configure PostgreSQL startup options
- URL based configuration
- choice of native-tls vs rustls
- 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
}
```## 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](LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT)at your option.
PostgreSQL is covered under [The PostgreSQL License](https://opensource.org/licenses/postgresql).
## Notes
Supports using PostgreSQL binaries from:
* [theseus-rs/postgresql-binaries](https://github.com/theseus-rs/postgresql-binaries) (default)
* [zonkyio/embedded-postgres-binaries](https://github.com/zonkyio/embedded-postgres-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.## Prior Art
Projects that inspired this one:
* [zonkyio/embedded-postgres-binaries](https://github.com/zonkyio/embedded-postgres-binaries)
* [faokunega/pg-embed](https://github.com/faokunega/pg-embed)