12 breaking releases

new 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

#400 in Database interfaces

Download history 555/week @ 2024-09-19 452/week @ 2024-09-26 557/week @ 2024-10-03 607/week @ 2024-10-10 502/week @ 2024-10-17 668/week @ 2024-10-24 943/week @ 2024-10-31 1156/week @ 2024-11-07 845/week @ 2024-11-14 705/week @ 2024-11-21 697/week @ 2024-11-28 987/week @ 2024-12-05 839/week @ 2024-12-12 455/week @ 2024-12-19 365/week @ 2024-12-26 529/week @ 2025-01-02

2,378 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
~380K SLoC