Skip to main content

Crate dbkit

Crate dbkit 

Source
Expand description

Multi-backend database infrastructure.

Transactional writes go through sqlx’s Any driver, so the backend (Postgres, MySQL, or SQLite) is selected from the connection URL scheme. Analytical reads go through a pluggable Arrow-based engine (DuckDB or DataFusion), behind feature flags.

  • ConnectionManager — sqlx connection pool with auto-create DB
  • Cache — DashMap-based concurrent key-value cache with named buckets
  • BaseHandlerexecute_write (sqlx) / execute_read (Arrow) / execute_read_as (typed), plus transactional → analytical sync
  • InitializationHandler — backend-aware DDL migration executor

§Example

use dbkit::ConnectionManager;

// The URL scheme selects the backend: postgres:// , mysql:// , sqlite://
let conn = ConnectionManager::new("postgres://localhost/myapp").await?;

// `pool()` yields a sqlx `AnyPool`, usable across all supported backends.
let _pool = conn.pool();

Note: the write/read handlers and migration runner are being ported onto this pool; see the crate changelog for the current status.

Re-exports§

pub use config::Backend;
pub use config::ConfigBuilder;
pub use config::DbkitConfig;
pub use config::SslMode;
pub use analytical::arrow;

Modules§

config

Structs§

AnyRow
BaseHandler
Core query executor: transactional writes via sqlx, and optionally analytical reads via a pluggable ReadEngine (DuckDB or DataFusion).
Cache
Concurrent key-value cache with named buckets.
ClickHouseSource
A handle to a ClickHouse server queried over HTTP.
ConnectionManager
Multi-backend connection pool with optional automatic database creation.
InitializationHandler
Batch DDL migration executor with tracking.
PgHandler
Core query executor for native Postgres: rich-typed transactional writes via sqlx, and row-mapped analytical reads via DuckDB.
PgRow
Implementation of Row for PostgreSQL.
PoolStatus
Snapshot of connection pool health.
RecordBatch
A two-dimensional batch of column-oriented data with a defined schema.

Enums§

DbValue
A backend-neutral parameter value.
DbkitError
FetchMode
How many rows to expect from a query.
QueryResult
Result wrapper for write queries.
WriteOp
Unified write operation types.

Traits§

ReadEngine
An analytical query engine that returns columnar Arrow data.
RemoteSink
A remote analytical store you can bulk-load Arrow data into.
RemoteSinkExt
Typed writing for any RemoteSink.
RemoteSource
An external analytical database queried over the network, returning Arrow.
RemoteSourceExt
Typed querying for any RemoteSource.
Row
Represents a single row from the database.

Type Aliases§

AnyPool
PgPool
An alias for Pool, specialized for Postgres.