3 releases
0.1.2 | Aug 22, 2024 |
---|---|
0.1.1 | Aug 16, 2024 |
0.1.0 | Aug 15, 2024 |
#2387 in Database interfaces
114 downloads per month
16KB
146 lines
bb8-libsql
A simple connection pooling manager for libsql using bb8.
lib.rs
:
Sqlite support for the bb8
connection pool.
Library crate: bb8-libsql
Integrated with: bb8 and libsql
Example
use std::{env, error::Error};
use r2d2_libsql::LibsqlConnectionManager;
use dotenvy::dotenv;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
dotenv().ok();
let url = env::var("LIBSQL_CLIENT_URL").unwrap();
let token = env::var("LIBSQL_CLIENT_TOKEN").unwrap();
let manager = LibsqlConnectionManager::remote(&url, &token);
let pool = bb8::Pool::builder()
.max_size(15)
.build(manager)
.await
.unwrap();
let conn = pool.get().await?;
let mut rows = conn.query("SELECT 1;", ()).await?;
let value_found = rows.next().await?
.map(|row| row.get::<u64>(0))
.transpose()?;
dbg!(value_found);
Ok(())
}
Dependencies
~4–11MB
~102K SLoC