pub struct Tx<'a> { /* private fields */ }Expand description
Lightweight transaction wrapper for Postgres.
Implementations§
Source§impl Tx<'_>
impl Tx<'_>
Sourcepub async fn prepare(&self, sql: &str) -> Result<Prepared, SqlMiddlewareDbError>
pub async fn prepare(&self, sql: &str) -> Result<Prepared, SqlMiddlewareDbError>
Prepare a SQL statement tied to this transaction.
§Errors
Returns an error if the prepare call fails.
Sourcepub async fn execute_prepared(
&self,
prepared: &Prepared,
params: &[RowValues],
) -> Result<usize, SqlMiddlewareDbError>
pub async fn execute_prepared( &self, prepared: &Prepared, params: &[RowValues], ) -> Result<usize, SqlMiddlewareDbError>
Execute a parameterized DML statement and return the affected row count.
§Errors
Returns an error if parameter conversion, execution, or row-count conversion fails.
Sourcepub async fn execute_dml(
&self,
query: &str,
params: &[RowValues],
) -> Result<usize, SqlMiddlewareDbError>
pub async fn execute_dml( &self, query: &str, params: &[RowValues], ) -> Result<usize, SqlMiddlewareDbError>
Execute a parameterized DML statement without preparing and return affected rows.
§Errors
Returns an error if parameter conversion, execution, or row-count conversion fails.
Sourcepub async fn query_prepared(
&self,
prepared: &Prepared,
params: &[RowValues],
) -> Result<ResultSet, SqlMiddlewareDbError>
pub async fn query_prepared( &self, prepared: &Prepared, params: &[RowValues], ) -> Result<ResultSet, SqlMiddlewareDbError>
Execute a parameterized SELECT and return a ResultSet.
§Errors
Returns an error if parameter conversion, execution, or result building fails.
Sourcepub async fn query(
&self,
query: &str,
params: &[RowValues],
) -> Result<ResultSet, SqlMiddlewareDbError>
pub async fn query( &self, query: &str, params: &[RowValues], ) -> Result<ResultSet, SqlMiddlewareDbError>
Execute a parameterized SELECT without preparing and return a ResultSet.
§Errors
Returns an error if parameter conversion or query execution fails.
Sourcepub async fn execute_batch(&self, sql: &str) -> Result<(), SqlMiddlewareDbError>
pub async fn execute_batch(&self, sql: &str) -> Result<(), SqlMiddlewareDbError>
Execute a batch of SQL statements inside the transaction.
§Errors
Returns an error if execution fails.
Sourcepub async fn commit(self) -> Result<TxOutcome, SqlMiddlewareDbError>
pub async fn commit(self) -> Result<TxOutcome, SqlMiddlewareDbError>
Trait Implementations§
Source§impl<'a> From<&'a Tx<'a>> for BatchTarget<'a>
Available on crate feature postgres only.
impl<'a> From<&'a Tx<'a>> for BatchTarget<'a>
postgres only.