Struct libsql_client::workers::Client
source · pub struct Client { /* private fields */ }
Expand description
Database client. This is the main structure used to communicate with the database.
Implementations§
source§impl Client
impl Client
sourcepub fn new(url: impl Into<String>, token: impl Into<String>) -> Self
pub fn new(url: impl Into<String>, token: impl Into<String>) -> Self
Creates a database client with JWT authentication.
Arguments
url
- URL of the database endpointtoken
- auth token
sourcepub fn from_credentials(
url: impl Into<String>,
username: impl Into<String>,
pass: impl Into<String>
) -> Self
pub fn from_credentials( url: impl Into<String>, username: impl Into<String>, pass: impl Into<String> ) -> Self
Creates a database client with Basic HTTP authentication.
Arguments
url
- URL of the database endpointusername
- database usernamepass
- user’s password
sourcepub fn from_config(config: Config) -> Self
pub fn from_config(config: Config) -> Self
Creates a database client from a Config
object.
sourcepub fn from_url<T: TryInto<Url>>(url: T) -> Result<Client>where
<T as TryInto<Url>>::Error: Display,
pub fn from_url<T: TryInto<Url>>(url: T) -> Result<Client>where <T as TryInto<Url>>::Error: Display,
sourcepub fn from_ctx<D>(ctx: &RouteContext<D>) -> Result<Self>
pub fn from_ctx<D>(ctx: &RouteContext<D>) -> Result<Self>
Establishes a database client from Cloudflare Workers context. Expects the context to contain the following secrets defined:
LIBSQL_CLIENT_URL
LIBSQL_CLIENT_USER
LIBSQL_CLIENT_PASS
Arguments
ctx
- Cloudflare Workers route context
Trait Implementations§
source§impl DatabaseClient for Client
impl DatabaseClient for Client
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