Struct libsql::Transaction
source · pub struct Transaction { /* private fields */ }
Expand description
A transaction on some connection.
Implementations§
Methods from Deref<Target = Connection>§
sourcepub async fn execute(&self, sql: &str, params: impl IntoParams) -> Result<u64>
pub async fn execute(&self, sql: &str, params: impl IntoParams) -> Result<u64>
Execute sql query provided some type that implements IntoParams
returning
on success the number of rows that were changed.
§Example
conn.execute("INSERT INTO foo (id) VALUES (?1)", [42]).await.unwrap();
conn.execute("INSERT INTO foo (id, name) VALUES (?1, ?2)", params![42, "baz"]).await.unwrap();
For more info on how to pass params check IntoParams
’s docs.
sourcepub async fn execute_batch(&self, sql: &str) -> Result<()>
pub async fn execute_batch(&self, sql: &str) -> Result<()>
Execute a batch set of statements.
sourcepub async fn query(&self, sql: &str, params: impl IntoParams) -> Result<Rows>
pub async fn query(&self, sql: &str, params: impl IntoParams) -> Result<Rows>
Execute sql query provided some type that implements IntoParams
returning
on success the Rows
.
§Example
conn.query("SELECT foo FROM bar WHERE id = ?1", [42]).await.unwrap();
conn.query("SELECT foo FROM bar WHERE id = ?1 AND name = ?2", params![42, "baz"]).await.unwrap();
For more info on how to pass params check IntoParams
’s docs and on how to
extract values out of the rows check the Rows
docs.
sourcepub async fn transaction(&self) -> Result<Transaction>
pub async fn transaction(&self) -> Result<Transaction>
Begin a new transaction in DEFERRED
mode, which is the default.
sourcepub async fn transaction_with_behavior(
&self,
tx_behavior: TransactionBehavior
) -> Result<Transaction>
pub async fn transaction_with_behavior( &self, tx_behavior: TransactionBehavior ) -> Result<Transaction>
Begin a new transaction in the given TransactionBehavior
.
sourcepub fn is_autocommit(&self) -> bool
pub fn is_autocommit(&self) -> bool
Check weather libsql is in autocommit
or not.
sourcepub fn last_insert_rowid(&self) -> i64
pub fn last_insert_rowid(&self) -> i64
Check the last inserted row id.
pub async fn reset(&self)
Trait Implementations§
source§impl Deref for Transaction
impl Deref for Transaction
§type Target = Connection
type Target = Connection
The resulting type after dereferencing.
source§fn deref(&self) -> &Connection
fn deref(&self) -> &Connection
Dereferences the value.
Auto Trait Implementations§
impl Freeze for Transaction
impl !RefUnwindSafe for Transaction
impl Send for Transaction
impl Sync for Transaction
impl Unpin for Transaction
impl !UnwindSafe for Transaction
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request