Skip to content

A copy to proxy dependencies for Tiberius beta testing

Notifications You must be signed in to change notification settings

GyrusSolutions/bb8-tiberius

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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();

About

A copy to proxy dependencies for Tiberius beta testing

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%