tank-postgres
tank-postgres is the Postgres driver for Tank: the Rust data layer.
It maps Tank operations and queries to native Postgres commands. Use it with the main tank crate, which provides entity definitions and the query API.
📘 Docs: https://tankhq.github.io/tank
🖥️ Repo: https://github.com/TankHQ/tank
📦 Crate: https://crates.io/crates/tank-postgres
Features
- Async connection and execution via
tokio-postgres - TLS via
postgres-openssl - Fast bulk inserts using the COPY binary protocol
Install
Quick Start
use ;
use PostgresDriver;
let driver = new;
let pool = driver
.connect_pool
.await?;
let mut connection = pool.get.await?;
Run this inside an async function. The returned connection can execute Tank entity operations.
Certificate filenames are resolved relative to the working directory. Use paths appropriate for your deployment.
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 on Linux:
- Add your user to the
dockergroup if needed on Linux:
[!CAUTION] Avoid aborting tests mid-run (e.g. killing the process at a breakpoint). Containers might be left running and consume resources.
List containers:
Stop container: