Skip to main content

Crate zeph_db

Crate zeph_db 

Source
Expand description

Database abstraction layer for Zeph.

Provides DbPool, DbRow, DbTransaction, DbQueryResult type aliases that resolve to either SQLite or PostgreSQL types at compile time, based on the active feature flag (sqlite or postgres).

The sql! macro converts ? placeholders to $N style for PostgreSQL, and is a no-op identity for SQLite (returning &'static str directly).

§Feature Flags

Exactly one of sqlite or postgres must be enabled. The root workspace default includes zeph-db/sqlite. Enabling both simultaneously triggers a compile_error!. Using --all-features is intentionally unsupported; use --features full or --features full,postgres instead.

Re-exports§

pub use bounds::FullDriver;
pub use dialect::Dialect;
pub use dialect::Postgres;
pub use dialect::Sqlite;
pub use driver::DatabaseDriver;
pub use error::DbError;
pub use migrate::run_migrations;
pub use pool::DbConfig;
pub use pool::redact_url;
pub use transaction::begin;
pub use transaction::begin_write;
pub use sqlx;

Modules§

bounds
FullDriver blanket super-trait for reducing sqlx bound repetition.
dialect
driver
DatabaseDriver trait and per-backend implementations.
error
fts
migrate
pool
query
Types and traits for the query family of functions and macros.
transaction

Macros§

query
Statically checked SQL query with println!() style syntax.
query_as
A variant of query! which takes a path to an explicitly defined struct as the output type.
query_scalar
A variant of query! which expects a single column from the query and evaluates to an instance of QueryScalar.
sql
Convert SQL with ? placeholders to the active backend’s placeholder style.

Structs§

QueryBuilder
A builder type for constructing queries at runtime.

Enums§

SqlxError
Represents all the ways a method can fail within SQLx.

Traits§

Executor
A type that contains or can provide a database connection to use for executing queries against the database.
FromRow
A record that can be built from a row returned by the database.
Row
Represents a single row from the database.

Functions§

is_postgres_url
Returns true if the given database URL looks like a PostgreSQL connection string.
numbered_placeholder
Generate a single numbered placeholder for bind position n (1-based).
placeholder_list
Generate a comma-separated list of placeholders for count binds starting at position start (1-based).
query
Execute a single SQL query as a prepared statement (transparently cached).
query_as
Execute a single SQL query as a prepared statement (transparently cached). Maps rows to Rust types using FromRow.
query_scalar
Execute a single SQL query as a prepared statement (transparently cached) and extract the first column of each row.
rewrite_placeholders
Rewrite ? bind markers to $1, $2, ... for PostgreSQL.

Type Aliases§

ActiveDialect
The active SQL dialect type.
ActiveDriver
The active database driver, selected at compile time.
DbPool
A connection pool for the active database backend.
DbQueryResult
A query result from the active database backend.
DbRow
A row from the active database backend.
DbTransaction
A transaction on the active database backend.

Derive Macros§

FromRow