Struct libsql::transaction::Transaction
source · pub struct Transaction { /* private fields */ }Implementations§
source§impl Transaction
impl Transaction
pub fn drop_behavior(&self) -> DropBehavior
pub fn set_drop_behavior(&mut self, drop_behavior: DropBehavior)
Methods from Deref<Target = Connection>§
sourcepub fn disconnect(&self)
pub fn disconnect(&self)
Disconnect from the database.
sourcepub fn query<S, P>(&self, sql: S, params: P) -> Result<Option<Rows>>where
S: Into<String>,
P: TryInto<Params>,
P::Error: Into<Box<dyn Error + Send + Sync>>,
pub fn query<S, P>(&self, sql: S, params: P) -> Result<Option<Rows>>where S: Into<String>, P: TryInto<Params>, P::Error: Into<Box<dyn Error + Send + Sync>>,
Convenience method to run a prepared statement query.
Example
conn.query("SELECT * FROM users WHERE name = ?1;", vec![libsql::Value::from(1)])sourcepub fn execute_batch<S>(&self, sql: S) -> Result<()>where
S: Into<String>,
pub fn execute_batch<S>(&self, sql: S) -> Result<()>where S: Into<String>,
Convenience method to run multiple SQL statements (that cannot take any parameters).
Example
conn.execute_batch(
"BEGIN;
CREATE TABLE foo(x INTEGER);
CREATE TABLE bar(y TEXT);
COMMIT;",
)Failure
Will return Err if sql cannot be converted to a C-compatible string
or if the underlying SQLite call fails.
sourcepub fn execute<S, P>(&self, sql: S, params: P) -> Result<u64>where
S: Into<String>,
P: TryInto<Params>,
P::Error: Into<Box<dyn Error + Send + Sync>>,
pub fn execute<S, P>(&self, sql: S, params: P) -> Result<u64>where S: Into<String>, P: TryInto<Params>, P::Error: Into<Box<dyn Error + Send + Sync>>,
Execute the SQL statement synchronously.
If you execute a SQL query statement (e.g. SELECT statement) that
returns the number of rows changed.
This method blocks the thread until the SQL statement is executed.
sourcepub fn execute_async<S, P>(&self, sql: S, params: P) -> RowsFuture ⓘwhere
S: Into<String>,
P: Into<Params>,
pub fn execute_async<S, P>(&self, sql: S, params: P) -> RowsFuture ⓘwhere S: Into<String>, P: Into<Params>,
Execute the SQL statement synchronously.
This method never blocks the thread until, but instead returns a
RowsFuture object immediately that can be used to deferredly
execute the statement.
sourcepub fn transaction(&self) -> Result<Transaction>
pub fn transaction(&self) -> Result<Transaction>
Begin a new transaction in DEFERRED mode, which is the default.
sourcepub fn transaction_with_behavior(
&self,
tx_behavior: TransactionBehavior
) -> Result<Transaction>
pub fn transaction_with_behavior( &self, tx_behavior: TransactionBehavior ) -> Result<Transaction>
Begin a new transaction in the given mode.
pub fn is_autocommit(&self) -> bool
pub fn changes(&self) -> u64
pub fn last_insert_rowid(&self) -> i64
Trait Implementations§
source§impl Deref for Transaction
impl Deref for Transaction
§type Target = Connection
type Target = Connection
source§fn deref(&self) -> &Connection
fn deref(&self) -> &Connection
Auto Trait Implementations§
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
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>
T in a tonic::Request