Expand description
Reusable Postgres + DuckDB database infrastructure.
Provides the foundational components for projects that use Postgres for writes and optionally DuckDB for analytical reads:
ConnectionManager— Postgres connection pool with auto-create DBCache— DashMap-based concurrent key-value cache with named bucketsBaseHandler— Unifiedexecute_write(Postgres) /execute_read(DuckDB)InitializationHandler— Batch DDL migration executor
§Example
use dbkit::{ConnectionManager, BaseHandler, InitializationHandler};
let conn = ConnectionManager::new("postgres://localhost/myapp").await?;
let pool = std::sync::Arc::new(conn.pool().clone());
// Run migrations
let init = InitializationHandler::new(pool.clone());
let sql = "CREATE TABLE IF NOT EXISTS users (id SERIAL PRIMARY KEY, name TEXT)";
init.run_migrations(sql).await?;
// Use the handler for queries
let handler = BaseHandler::new(pool);Re-exports§
pub use config::ConfigBuilder;pub use config::DbkitConfig;pub use config::SslMode;
Modules§
Structs§
- Base
Handler - Core query executor for Postgres writes and optionally DuckDB reads.
- Cache
- Concurrent key-value cache with named buckets.
- Connection
Manager - Postgres connection pool with automatic database creation.
- Initialization
Handler - Batch DDL migration executor with tracking.
- PgRow
- A row of data returned from the database by a query.
- Pool
Status - Snapshot of connection pool health.
Enums§
- Dbkit
Error - Fetch
Mode - How many rows to expect from a query.
- Query
Result - Result wrapper for Postgres write queries.
- WriteOp
- Unified write operation types for Postgres.
Type Aliases§
- Pool
- Type alias for using
deadpool::managed::Poolwithtokio_postgres.