Struct libsql_client::spin::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,
pub fn raw_batch( &self, stmts: impl IntoIterator<Item = impl Into<Statement>> ) -> Result<BatchResult>
source§impl Client
impl Client
sourcepub fn execute(&self, stmt: impl Into<Statement>) -> Result<ResultSet>
pub fn execute(&self, stmt: impl Into<Statement>) -> Result<ResultSet>
Executes a single SQL statement.
sourcepub fn batch(
&self,
stmts: impl IntoIterator<Item = impl Into<Statement>>
) -> Result<Vec<ResultSet>>
pub fn batch( &self, stmts: impl IntoIterator<Item = impl Into<Statement>> ) -> Result<Vec<ResultSet>>
Executes a batch of SQL statements, wrapped in “BEGIN”, “END”, transaction-style. Each statement is going to run in its own transaction, unless they’re wrapped in BEGIN and END
Arguments
stmts
- SQL statements
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnwindSafe for Client
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