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. When both are enabled simultaneously,
postgres takes priority. Use --features full for the standard SQLite build.
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
FullDriverblanket super-trait for reducing sqlx bound repetition.- dialect
- driver
DatabaseDrivertrait and per-backend implementations.- error
- fts
- migrate
- pool
- query
- Types and traits for the
queryfamily 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§
- Query
Builder - A builder type for constructing queries at runtime.
Enums§
- Sqlx
Error - 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
trueif the given database URL looks like aPostgreSQLconnection string. - numbered_
placeholder - Generate a single numbered placeholder for bind position
n(1-based). - placeholder_
list - Generate a comma-separated list of placeholders for
countbinds starting at positionstart(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, ...forPostgreSQL.
Type Aliases§
- Active
Dialect - The active SQL dialect type.
- Active
Driver - The active database driver, selected at compile time.
- DbPool
- A connection pool for the active database backend.
- DbQuery
Result - A query result from the active database backend.
- DbRow
- A row from the active database backend.
- DbTransaction
- A transaction on the active database backend.