pub struct Tx<'a> { /* private fields */ }Expand description
Transaction handle that owns the SQLite connection until completion.
Implementations§
Source§impl Tx<'_>
impl Tx<'_>
Sourcepub fn prepare(&self, sql: &str) -> Result<Prepared, SqlMiddlewareDbError>
pub fn prepare(&self, sql: &str) -> Result<Prepared, SqlMiddlewareDbError>
Prepare a statement within this transaction.
§Errors
Returns SqlMiddlewareDbError if the transaction has already completed.
Sourcepub async fn execute_prepared(
&mut self,
prepared: &Prepared,
params: &[RowValues],
) -> Result<usize, SqlMiddlewareDbError>
pub async fn execute_prepared( &mut self, prepared: &Prepared, params: &[RowValues], ) -> Result<usize, SqlMiddlewareDbError>
Execute a prepared statement as DML within this transaction.
§Errors
Returns SqlMiddlewareDbError if parameter conversion or execution fails.
Sourcepub async fn query_prepared(
&mut self,
prepared: &Prepared,
params: &[RowValues],
) -> Result<ResultSet, SqlMiddlewareDbError>
pub async fn query_prepared( &mut self, prepared: &Prepared, params: &[RowValues], ) -> Result<ResultSet, SqlMiddlewareDbError>
Execute a prepared statement as a query within this transaction.
§Errors
Returns SqlMiddlewareDbError if parameter conversion or execution fails.
Sourcepub async fn execute_batch(
&mut self,
sql: &str,
) -> Result<(), SqlMiddlewareDbError>
pub async fn execute_batch( &mut self, sql: &str, ) -> Result<(), SqlMiddlewareDbError>
Execute a batch inside the open transaction.
§Errors
Returns SqlMiddlewareDbError if executing the batch fails.
Trait Implementations§
Source§impl Drop for Tx<'_>
impl Drop for Tx<'_>
Source§fn drop(&mut self)
fn drop(&mut self)
Rolls back on drop to avoid leaking open transactions; the rollback is best-effort and
SQLite may report “no transaction is active” if the transaction was already completed
by user code (e.g., via execute_batch_in_tx). Such errors are ignored because the goal
is simply to leave the connection in a clean state before returning it to the pool.