12 breaking releases
Uses new Rust 2024
| 0.16.0 | Jan 20, 2026 |
|---|---|
| 0.14.2 | Jan 4, 2026 |
| 0.13.0 | Dec 29, 2025 |
| 0.10.0 | Nov 11, 2025 |
#7 in #data-layer
290KB
7.5K
SLoC
tank-postgres
Postgres driver implementation for Tank: the Rust data layer.
Implements Tank’s Driver and related traits for Postgres, mapping Tank operations and queries into direct Postgres commands. It does not replace the main tank crate. you still use it to define entities, manage schemas, and build queries.
https://tankhq.github.io/tank/
https://github.com/TankHQ/tank ⭐
Features
- Async connection and execution via
tokio-postgres - TLS via
postgres-openssl - Fast bulk inserts using the COPY binary protocol
Install
cargo add tank
cargo add tank-postgres
Quick Start
use tank::{Connection, Driver, Executor};
use tank_postgres::PostgresDriver;
let driver = PostgresDriver::new();
let connection = driver
.connect("postgres://user:pass@hostname:5432/database?sslmode=require&sslrootcert=/path/to/root.crt&sslcert=/path/to/client.crt&sslkey=/path/to/client.key".into())
.await?;
Running Tests
Tests need a Postgres instance. Provide a connection URL via TANK_POSTGRES_TEST. If absent, a containerized Postgres will be launched automatically using testcontainers-modules.
- Ensure Docker is running (linux):
systemctl status docker
- Add your user to the
dockergroup if needed (linux):
sudo usermod -aG docker $USER
[!CAUTION] Avoid aborting tests mid‑run (e.g. killing the process at a breakpoint). Containers might be left running and consume resources.
List containers:
docker psStop container:
docker kill <container_id_or_name>
Dependencies
~16–34MB
~529K SLoC