Expand description
§Turso bindings for Rust
Turso is an in-process SQL database engine, compatible with SQLite.
§Getting Started
To get started, you first need to create a Database
object and then open a Connection
to it, which you use to query:
use turso::Builder;
let db = Builder::new_local(":memory:").build().await.unwrap();
let conn = db.connect().unwrap();
conn.execute("CREATE TABLE IF NOT EXISTS users (email TEXT)", ()).await.unwrap();
conn.execute("INSERT INTO users (email) VALUES ('alice@example.org')", ()).await.unwrap();
You can also prepare statements with the Connection
object and then execute the Statement
objects:
let mut stmt = conn.prepare("SELECT * FROM users WHERE email = ?1").await.unwrap();
let mut rows = stmt.query(["foo@example.com"]).await.unwrap();
let row = rows.next().await.unwrap().unwrap();
let value = row.get_value(0).unwrap();
println!("Row: {:?}", value);
Re-exports§
pub use value::Value;
pub use params::params_from_iter;
pub use params::IntoParams;
Modules§
- params
- This module contains all
Param
related utilities and traits. - transaction
- value
Macros§
- named_
params - Construct named params from a hetergeneous set of params types.
- params
- Construct positional params from a hetergeneous set of params types.
Structs§
- Builder
- A builder for
Database
. - Column
- Column information.
- Connection
- A database connection.
- Database
- A database.
- Row
- Query result row.
- Rows
- Results of a prepared statement query.
- Statement
- A prepared statement.
- Transaction