Struct libsql_client::local::Connection  
source · pub struct Connection { /* private fields */ }Expand description
Database connection. This is the main structure used to communicate with the database.
Implementations§
source§impl Connection
 
impl Connection
pub fn connect_from_env() -> Result<Self>
sourcepub async fn batch(
    &self,
    stmts: impl IntoIterator<Item = impl Into<Statement>>
) -> Result<Vec<QueryResult>>
 
pub async fn batch( &self, stmts: impl IntoIterator<Item = impl Into<Statement>> ) -> Result<Vec<QueryResult>>
Executes a batch of SQL statements. Each statement is going to run in its own transaction, unless they’re wrapped in BEGIN and END
Arguments
- stmts- SQL statements
Examples
let db = libsql_client::local::Connection::connect("/tmp/example321.db").unwrap();
let result = db
    .batch(["CREATE TABLE t(id)", "INSERT INTO t VALUES (42)"])
    .await;Trait Implementations§
source§impl Connection for Connection
 
impl Connection for Connection
source§fn batch<'life0, 'async_trait>(
    &'life0 self,
    stmts: impl 'async_trait + IntoIterator<Item = impl 'async_trait + Into<Statement>>
) -> Pin<Box<dyn Future<Output = Result<Vec<QueryResult>>> + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
 
fn batch<'life0, 'async_trait>( &'life0 self, stmts: impl 'async_trait + IntoIterator<Item = impl 'async_trait + Into<Statement>> ) -> Pin<Box<dyn Future<Output = Result<Vec<QueryResult>>> + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Executes a batch of SQL statements.
Each statement is going to run in its own transaction,
unless they’re wrapped in BEGIN and END Read more
source§fn execute<'life0, 'async_trait>(
    &'life0 self,
    stmt: impl 'async_trait + Into<Statement>
) -> Pin<Box<dyn Future<Output = Result<QueryResult>> + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
 
fn execute<'life0, 'async_trait>( &'life0 self, stmt: impl 'async_trait + Into<Statement> ) -> Pin<Box<dyn Future<Output = Result<QueryResult>> + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Executes a single SQL statement Read more
source§fn transaction<'life0, 'async_trait>(
    &'life0 self,
    stmts: impl 'async_trait + IntoIterator<Item = impl 'async_trait + Into<Statement>>
) -> Pin<Box<dyn Future<Output = Result<Vec<QueryResult>>> + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
 
fn transaction<'life0, 'async_trait>( &'life0 self, stmts: impl 'async_trait + IntoIterator<Item = impl 'async_trait + Into<Statement>> ) -> Pin<Box<dyn Future<Output = Result<Vec<QueryResult>>> + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Executes an SQL transaction.
Does not support nested transactions - do not use BEGIN or END
inside a transaction. Read more