Crates.io | deadpool-diesel |
lib.rs | deadpool-diesel |
version | 0.6.1 |
source | src |
created_at | 2021-07-14 13:04:24.637798 |
updated_at | 2024-05-04 09:26:17.110177 |
description | Dead simple async pool for diesel |
homepage | |
repository | https://github.com/bikeshedder/deadpool |
max_upload_size | |
id | 422713 |
size | 34,546 |
Deadpool is a dead simple async pool for connections and objects of any type.
This crate implements a deadpool
manager for diesel
connections.
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 |
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(())
}
Licensed under either of
at your option.