Skip to main content

architect_sdk/db/
pool.rs

1//! Feature-gated type aliases for the active database pool and connection.
2//!
3//! Only one dialect feature may be active at a time (enforced by build.rs).
4//! Code that imports `db::pool::Pool` compiles to the concrete sqlx type with zero overhead.
5
6#[cfg(feature = "postgres")]
7pub use sqlx::postgres::PgRow as DbRow;
8#[cfg(feature = "postgres")]
9pub use sqlx::PgConnection as Connection;
10#[cfg(feature = "postgres")]
11pub use sqlx::PgPool as Pool;
12#[cfg(feature = "postgres")]
13pub type DbConnection = sqlx::pool::PoolConnection<sqlx::Postgres>;
14#[cfg(feature = "postgres")]
15pub type DbTransaction = sqlx::Transaction<'static, sqlx::Postgres>;
16
17#[cfg(feature = "mysql")]
18pub use sqlx::mysql::MySqlRow as DbRow;
19#[cfg(feature = "mysql")]
20pub use sqlx::MySqlConnection as Connection;
21#[cfg(feature = "mysql")]
22pub use sqlx::MySqlPool as Pool;
23#[cfg(feature = "mysql")]
24pub type DbConnection = sqlx::pool::PoolConnection<sqlx::MySql>;
25#[cfg(feature = "mysql")]
26pub type DbTransaction = sqlx::Transaction<'static, sqlx::MySql>;
27
28#[cfg(feature = "sqlite")]
29pub use sqlx::sqlite::SqliteRow as DbRow;
30#[cfg(feature = "sqlite")]
31pub use sqlx::SqliteConnection as Connection;
32#[cfg(feature = "sqlite")]
33pub use sqlx::SqlitePool as Pool;
34#[cfg(feature = "sqlite")]
35pub type DbConnection = sqlx::pool::PoolConnection<sqlx::Sqlite>;
36#[cfg(feature = "sqlite")]
37pub type DbTransaction = sqlx::Transaction<'static, sqlx::Sqlite>;