mirror of
https://github.com/trailbaseio/trailbase
synced 2026-04-25 23:37:40 +00:00
Note that this complicates the APIs, since it pushes the responsibility of declaring a query a read or write to the user to then be scheduled appropriately. Add `.(read_|)query_row_f` APIs similar to rusqlites `conn.query_row` accepting a `|row| -> Result<T>` to reduce the use of `Row` and `Rows`. Make benchmarks more isolated by not sharing a DB across runs accumulating writes.
16 lines
517 B
Rust
16 lines
517 B
Rust
/// This is a very simple binary demonstrating how TrailBase's SQLite extensions (e.g. uuid_v7)
|
|
/// can be used outside of TrailBase, thus avoiding lock-in.
|
|
use trailbase_extension::connect_sqlite;
|
|
use trailbase_sqlite::Connection;
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
let conn = Connection::new(|| connect_sqlite(None, None), None).expect("in memory connection");
|
|
|
|
let uuid: Option<String> = conn
|
|
.read_query_value("SELECT (uuid_text(uuid_v7()))", ())
|
|
.await
|
|
.unwrap();
|
|
|
|
println!("Done! {uuid:?}");
|
|
}
|