#connection-pool #bb8-connection #bb8 #connection-manager #sqlite #pool

bin+lib bb8-libsql

A simple connection pooling manager for libsql using bb8

3 releases

0.1.2 Aug 22, 2024
0.1.1 Aug 16, 2024
0.1.0 Aug 15, 2024

#2387 in Database interfaces

Download history 148/week @ 2024-08-18 12/week @ 2024-08-25 6/week @ 2024-09-22 4/week @ 2024-09-29 1/week @ 2024-10-13 17/week @ 2024-11-03

114 downloads per month

MIT license

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