#tiberius #mssql

bb8-tiberius

bb8 connection manager for Tiberius

12 breaking releases

0.16.0 Jan 8, 2025
0.15.0 Feb 14, 2023
0.14.0 Feb 5, 2023
0.13.0 Sep 7, 2022
0.1.0 Jul 11, 2019

#1075 in Database interfaces

Download history 2074/week @ 2026-01-08 2067/week @ 2026-01-15 1484/week @ 2026-01-22 1874/week @ 2026-01-29 2108/week @ 2026-02-05 2364/week @ 2026-02-12 2740/week @ 2026-02-19 3282/week @ 2026-02-26 2920/week @ 2026-03-05 3236/week @ 2026-03-12 4057/week @ 2026-03-19 3907/week @ 2026-03-26 3404/week @ 2026-04-02 4578/week @ 2026-04-09 4109/week @ 2026-04-16 3629/week @ 2026-04-23

16,238 downloads per month
Used in 25 crates (10 directly)

MIT license

13KB
148 lines

bb8-tiberius

Use bb8 (pool manager for async connections) with Tiberius (MSSQL driver for Rust).

Usage

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let conn_str = std::env::var("DB_CONN")?;

    let mgr = bb8_tiberius::ConnectionManager::build(conn_str.as_str())?;

    let pool = bb8::Pool::builder().max_size(2).build(mgr).await?;

    let mut conn = pool.get().await?;

    let res = conn
        .simple_query("SELECT @@version")
        .await?
        .into_first_result()
        .await?
        .into_iter()
        .map(|row| {
            let val: &str = row.get(0).unwrap();
            String::from(val)
        })
        .collect::<Vec<_>>();

    println!("{:?}", &res);

    Ok(())
}

If using a named instance to connect, use the using_named_connection function:

let mgr = bb8_tiberius::ConnectionManager::build(conn_str.as_str())?.using_named_connection();

Dependencies

~11–29MB
~415K SLoC