Struct libsql::Connection
source · pub struct Connection { /* private fields */ }
Expand description
A connection to some libsql database, this can be a remote one or a local one.
Implementations§
source§impl Connection
impl 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 Clone for Connection
impl Clone for Connection
source§fn clone(&self) -> Connection
fn clone(&self) -> Connection
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for Connection
impl !RefUnwindSafe for Connection
impl Send for Connection
impl Sync for Connection
impl Unpin for Connection
impl !UnwindSafe for Connection
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