mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-17 16:44:19 +01:00
This reverts commitbd60cd214c, reversing changes made to74e48a3a8fbecause it makes limbo_stress hang.
41 lines
942 B
Rust
41 lines
942 B
Rust
use turso::Builder;
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
let db = Builder::new_local(":memory:").build().await.unwrap();
|
|
|
|
let conn = db.connect().unwrap();
|
|
|
|
conn.query("select 1; select 1;", ()).await.unwrap();
|
|
|
|
conn.execute("CREATE TABLE IF NOT EXISTS users (email TEXT)", ())
|
|
.await
|
|
.unwrap();
|
|
|
|
conn.pragma_query("journal_mode", |row| {
|
|
println!("{:?}", row.get_value(0));
|
|
Ok(())
|
|
})
|
|
.unwrap();
|
|
|
|
let mut stmt = conn
|
|
.prepare("INSERT INTO users (email) VALUES (?1)")
|
|
.await
|
|
.unwrap();
|
|
|
|
stmt.execute(["foo@example.com"]).await.unwrap();
|
|
|
|
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);
|
|
}
|