9 releases

0.1.8 Mar 20, 2024
0.1.7 Jan 16, 2024
0.1.6 Nov 1, 2023
0.1.5 Oct 19, 2023
0.1.2 Jun 11, 2023

#2225 in Database interfaces

Download history 67/week @ 2024-09-11 81/week @ 2024-09-18 122/week @ 2024-09-25 62/week @ 2024-10-02 104/week @ 2024-10-09 36/week @ 2024-10-16 14/week @ 2024-10-23 55/week @ 2024-10-30 25/week @ 2024-11-06 32/week @ 2024-11-13 53/week @ 2024-11-20 166/week @ 2024-11-27 133/week @ 2024-12-04 71/week @ 2024-12-11 117/week @ 2024-12-18 56/week @ 2024-12-25

418 downloads per month
Used in ssql

MIT/Apache

19KB
272 lines

Deadpool & Tiberius simple impl

This crate served as connector and re-exporter of tiberius && deadpool to make create sql server connection pool easier.
If you are looking for sql server ORM, take a look at ssql.

For full documentation pls visit doc.rs.

Example, chaining configs from tiberius and configs from pooling

use deadpool_tiberius;

#[tokio::main]
async fn main() -> deadpool_tiberius::SqlServerResult<()> {
    let pool = deadpool_tiberius::Manager::new()
        .host("localhost") // default to localhost
        .port(1433) // default to 
        .basic_authentication("username", "password")
        //  or .authentication(tiberius::AuthMethod)
        .database("database1")
        .trust_cert()
        .max_size(10)
        .wait_timeout(1.52)  // in seconds, default to no timeout
        .pre_recycle_sync(|_client, _metrics| {
            // do sth with client object and pool metrics
            Ok(())
        })
        .create_pool()?;

    let mut conn = pool.get().await?;
    let rows = conn.simple_query("SELECT 1");

    // Or construct server connection config from ADO string.
    const CONN_STR: &str = "Driver={SQL Server};Integrated Security=True;\
                            Server=DESKTOP-TTTTTTT;Database=master;\
                            Trusted_Connection=yes;encrypt=DANGER_PLAINTEXT;";
    let _pool = deadpool_tiberius::Manager::from_ado_string(CONN_STR)
        .max_size(20)
        .create_pool()?;
}

Dependencies

~8–20MB
~355K SLoC