11 unstable releases (5 breaking)

0.6.1 May 4, 2024
0.6.0 Mar 31, 2024
0.5.0 Sep 26, 2023
0.4.1 Dec 9, 2022
0.1.2 Jul 16, 2021

#7 in #connection-manager

Download history 3283/week @ 2024-07-30 3303/week @ 2024-08-06 2660/week @ 2024-08-13 2832/week @ 2024-08-20 2575/week @ 2024-08-27 2826/week @ 2024-09-03 2647/week @ 2024-09-10 2769/week @ 2024-09-17 2953/week @ 2024-09-24 2242/week @ 2024-10-01 2161/week @ 2024-10-08 2358/week @ 2024-10-15 2293/week @ 2024-10-22 2365/week @ 2024-10-29 2671/week @ 2024-11-05 3017/week @ 2024-11-12

10,770 downloads per month

MIT/Apache

99KB
1.5K SLoC

Deadpool for Diesel Latest Version Unsafe forbidden Rust 1.75+

Deadpool is a dead simple async pool for connections and objects of any type.

This crate implements a deadpool manager for diesel connections.

Features

Feature Description Extra dependencies Default
sqlite Enable sqlite feature in diesel crate diesel/sqlite no
postgres Enable postgres feature in diesel crate diesel/postgres no
mysql Enable mysql feature in diesel crate diesel/mysql no
rt_tokio_1 Enable support for tokio crate deadpool/rt_tokio_1 yes
rt_async-std_1 Enable support for async-std crate deadpool/rt_async-std_1 no
serde Enable support for serde crate deadpool/serde no
tracing Enable support for tracing by propagating Spans in the interact() calls. Enable this if you use the tracing crate and you want to get useful traces from within interact() calls. deadpool-sync/tracing, tracing no

Example

use deadpool_diesel::sqlite::{Runtime, Manager, Pool};
use diesel::{prelude::*, select, sql_types::Text};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let manager = Manager::new(":memory:", Runtime::Tokio1);
    let pool = Pool::builder(manager)
        .max_size(8)
        .build()
        .unwrap();
    let conn = pool.get().await?;
    let result = conn.interact(|conn| {
        let query = select("Hello world!".into_sql::<Text>());
        query.get_result::<String>(conn)
    }).await??;
    assert!(result == "Hello world!");
    Ok(())
}

License

Licensed under either of

at your option.

Dependencies

~5–19MB
~276K SLoC