Struct libsql::connection::Connection
source · pub struct Connection { /* private fields */ }Expand description
A connection to a libSQL database.
Implementations§
source§impl Connection
impl Connection
sourcepub fn from_handle(raw: *mut sqlite3) -> Self
pub fn from_handle(raw: *mut sqlite3) -> Self
Create a connection from a raw handle to the underlying libSQL connection
sourcepub fn disconnect(&self)
pub fn disconnect(&self)
Disconnect from the database.
sourcepub fn prepare<S: Into<String>>(&self, sql: S) -> Result<Statement<'_>>
pub fn prepare<S: Into<String>>(&self, sql: S) -> Result<Statement<'_>>
Prepare the SQL statement.
sourcepub fn execute<S, P>(&self, sql: S, params: P) -> Result<Option<Rows>>where
S: Into<String>,
P: Into<Params>,
pub fn execute<S, P>(&self, sql: S, params: P) -> Result<Option<Rows>>where S: Into<String>, P: Into<Params>,
Execute the SQL statement synchronously.
If you execute a SQL query statement (e.g. SELECT statement) that
returns rows, then this method returns Some(Rows)on success; otherwise
this method returns None.
This method blocks the thread until the SQL statement is executed.
However, for SQL query statements, the method blocks only until the
first row is available. To fetch all rows, you need to call Rows::next()
consecutively.
sourcepub fn execute_async<S, P>(&self, sql: S, params: P) -> RowsFuture<'_> ⓘwhere
S: Into<String>,
P: Into<Params>,
pub fn execute_async<S, P>(&self, sql: S, params: P) -> RowsFuture<'_> ⓘwhere S: Into<String>, P: Into<Params>,
Execute the SQL statement synchronously.
This method never blocks the thread until, but instead returns a
RowsFuture object immediately that can be used to deferredly
execute the statement.