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
The tests manage their own throwaway containers via testcontainers-modules. No database setup is needed. Set environment variable TANK_POSTGRES_TEST to use your own server.
Docker is required:
- 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: