bb8-tiberius

Crates.iobb8-tiberius
lib.rsbb8-tiberius
version0.15.0
sourcesrc
created_at2019-07-11 16:57:10.092761
updated_at2023-02-14 13:37:56.059552
descriptionbb8 connection manager for Tiberius
homepage
repositoryhttps://github.com/kardeiz/bb8-tiberius
max_upload_size
id148345
size46,425
Jacob Brown (kardeiz)

documentation

README

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(())
}
Commit count: 53

cargo fmt