use crate::DbPool;
#[tracing::instrument(name = "db.tx.begin", skip_all, err)]
pub async fn begin(pool: &DbPool) -> Result<crate::DbTransaction<'_>, sqlx::Error> {
pool.begin().await
}
#[cfg(all(feature = "sqlite", not(feature = "postgres")))]
#[tracing::instrument(name = "db.tx.begin_write", skip_all, err)]
pub async fn begin_write(pool: &DbPool) -> Result<crate::DbTransaction<'_>, sqlx::Error> {
pool.begin_with("BEGIN IMMEDIATE").await
}
#[cfg(feature = "postgres")]
#[tracing::instrument(name = "db.tx.begin_write", skip_all, err)]
pub async fn begin_write(pool: &DbPool) -> Result<crate::DbTransaction<'_>, sqlx::Error> {
pool.begin().await
}