# RDF.rs: PostgreSQL Store
[](https://unlicense.org)
[](https://blog.rust-lang.org/2025/02/20/Rust-1.85.0/)
[](https://crates.io/crates/rdf-store-postgres)
[](https://docs.rs/rdf-store-postgres)
A [PostgreSQL] storage adapter for **[RDF.rs]** knowledge graphs.
> [!TIP]
> 🚧 _We are building in public. This is presently under heavy construction._
<sub>
[[Features](#-features)] |
[[Prerequisites](#%EF%B8%8F-prerequisites)] |
[[Installation](#%EF%B8%8F-installation)] |
[[Examples](#-examples)] |
[[Reference](#-reference)] |
[[Development](#%E2%80%8D-development)]
</sub>
## ✨ Features
- Implements a scalable, high-performance RDF store backed by [PostgreSQL].
- Built on async Rust using lazily-evaluated streams throughout.
- 100% pure and safe Rust with minimal dependencies and no bloat.
- Supports opting out of any feature using comprehensive [feature flags].
- Adheres to the Rust API Guidelines in its [naming conventions].
- Cuts red tape: 100% free and unencumbered public domain software.
## 🛠️ Prerequisites
- [Rust] 1.85+ (2024 edition)
## ⬇️ Installation
### Installation via Cargo
```bash
cargo add rdf-store-postgres
```
### Installation in `Cargo.toml`
Enable all default features:
```toml
[dependencies]
rdf-store-postgres = { version = "0.3" }
```
Enable only specific features:
```toml
[dependencies]
rdf-store-postgres = { version = "0.3", default-features = false, features = ["tls"] }
```
## 👉 Examples
### Running a PostgreSQL Server
```bash
docker run -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust postgres
```
### Importing the Library
```rust
use rdf_store_postgres::{PostgresStore, PostgresTransaction};
```
### Connecting to the Store
```rust,compile_fail
let mut store = PostgresStore::open("postgres://").await?;
```
### Mutating the Store
```rust,compile_fail
let mut tx = store.write().await?;
tx.remove(old_quad.into()).await?;
tx.insert(new_quad.into()).await?;
tx.commit().await?; // ...or:
//tx.rollback().await?;
```
### Accessing the Store
```rust,compile_fail
let tx = store.read().await?;
tx.r#match(quad_pattern)
.for_each(|quad| async move {
eprintln!("{:?}", quad);
})
.await;
```
## 📚 Reference
[docs.rs/rdf-store-postgres](https://docs.rs/rdf-store-postgres)
## 👨💻 Development
```bash
git clone https://github.com/rust-rdf/rdf.rs.git
```
---
[](https://x.com/intent/post?url=https://github.com/rust-rdf/rdf.rs/tree/master/lib/rdf-store-postgres&text=rdf-store-postgres)
[](https://reddit.com/submit?url=https://github.com/rust-rdf/rdf.rs/tree/master/lib/rdf-store-postgres&title=rdf-store-postgres)
[](https://news.ycombinator.com/submitlink?u=https://github.com/rust-rdf/rdf.rs/tree/master/lib/rdf-store-postgres&t=rdf-store-postgres)
[](https://www.facebook.com/sharer/sharer.php?u=https://github.com/rust-rdf/rdf.rs/tree/master/lib/rdf-store-postgres)
[](https://www.linkedin.com/sharing/share-offsite/?url=https://github.com/rust-rdf/rdf.rs/tree/master/lib/rdf-store-postgres)
[feature flags]: https://github.com/rust-rdf/rdf.rs/blob/master/lib/rdf-store-postgres/Cargo.toml
[naming conventions]: https://rust-lang.github.io/api-guidelines/naming.html
[PostgreSQL]: https://postgresql.org
[RDF]: https://www.w3.org/TR/rdf12-concepts/
[RDF.rs]: https://github.com/rust-rdf/rdf.rs
[Rust]: https://rust-lang.org