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

#396 in Database interfaces

Download history 614/week @ 2024-10-07 531/week @ 2024-10-14 701/week @ 2024-10-21 666/week @ 2024-10-28 1008/week @ 2024-11-04 1097/week @ 2024-11-11 772/week @ 2024-11-18 656/week @ 2024-11-25 844/week @ 2024-12-02 868/week @ 2024-12-09 794/week @ 2024-12-16 408/week @ 2024-12-23 318/week @ 2024-12-30 770/week @ 2025-01-06 990/week @ 2025-01-13 1282/week @ 2025-01-20

3,391 downloads per month
Used in 14 crates (4 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

~8–21MB
~377K SLoC