Skip to main content

Crate ch_database

Crate ch_database 

Source
Expand description

§ch-database

ch-database provides database lifecycle, migration, and object-storage primitives behind independent feature flags.

More information is available in the API documentation.

§High-level features

  • SQLx pool configuration, URL handling, retries, migrations, and health checks
  • SpacetimeDB connection lifecycle and serialized subscriptions
  • Local and S3-compatible object storage through a common API
  • Redacted diagnostics for connection strings and credentials
  • Application-owned schemas, account models, and authorization policy

§Feature flags

FeatureProvides
mariadbSQLx pool settings, URL handling, migrations, and health checks; enabled by default
spacetimedbConnection lifecycle, serialized subscriptions, endpoint state, and read-failure handling
s3Local filesystem and S3-compatible object storage

§Usage

use ch_database::mariadb::url::normalize_mysql_url;

let url = normalize_mysql_url("mysql://user:pass@localhost/example")?;
assert!(url.starts_with("mysql://"));

With s3 enabled, ObjectStoreClient supports local directories, Amazon S3, MinIO, and compatible endpoints. Object keys reject path traversal, absolute paths, and ambiguous separators. Buffered reads have a 64 MiB default limit; get_object exposes a streaming result for larger objects.

§Minimum supported Rust version

ch-database requires Rust 1.96 or newer.

§License

Licensed under the Sustainable Use License 1.0. See LICENSE.md.

Modules§

mariadb
MariaDB and SQLx integration. MariaDB helpers built on top of SQLx.
migration
SQL migration statement parsing.
s3
Local and S3-compatible object storage.
spacetimedb
SpacetimeDB connection lifecycle helpers. Shared SpacetimeDB helper utilities.