Struct libsql_client::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
sourcepub fn connect(
url: impl Into<String>,
username: impl Into<String>,
pass: impl Into<String>
) -> Self
pub fn connect(
url: impl Into<String>,
username: impl Into<String>,
pass: impl Into<String>
) -> Self
Establishes a database connection.
Arguments
url- URL of the database endpointusername- database usernamepass- user’s password
sourcepub fn connect_from_ctx<D>(ctx: &RouteContext<D>) -> Result<Self>
pub fn connect_from_ctx<D>(ctx: &RouteContext<D>) -> Result<Self>
Establishes a database connection from Cloudflare Workers context. Expects the context to contain the following variables defined:
LIBSQL_CLIENT_URLLIBSQL_CLIENT_USERLIBSQL_CLIENT_PASS
Arguments
ctx- Cloudflare Workers route context
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
sourcepub async fn transaction(
&self,
stmts: impl IntoIterator<Item = impl Into<Statement>>
) -> Result<Vec<QueryResult>>
pub async fn transaction(
&self,
stmts: impl IntoIterator<Item = impl Into<Statement>>
) -> Result<Vec<QueryResult>>
Executes an SQL transaction. Does not support nested transactions - do not use BEGIN or END inside a transaction.
Arguments
stmts- SQL statements
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 more