Crate deadpool_diesel

source ·
Expand description

§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

FeatureDescriptionExtra dependenciesDefault
sqliteEnable sqlite feature in diesel cratediesel/sqliteno
postgresEnable postgres feature in diesel cratediesel/postgresno
mysqlEnable mysql feature in diesel cratediesel/mysqlno
rt_tokio_1Enable support for tokio cratedeadpool/rt_tokio_1yes
rt_async-std_1Enable support for async-std cratedeadpool/rt_async-std_1no
serdeEnable support for serde cratedeadpool/serdeno
tracingEnable 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, tracingno

§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.

Modules§

  • mysqlmysql
    Type aliases for using deadpool-diesel with MySQL.
  • postgrespostgres
    Type aliases for using deadpool-diesel with PostgreSQL.
  • sqlitesqlite
    Type aliases for using deadpool-diesel with SQLite.

Structs§

Enums§

Type Aliases§