Deadpool is a dead simple async pool for connections and objects of any type.
Backend | Crate ----------------------------------------------------------- | ----- tokio-postgres | deadpool-postgres
deadpool-postgres
)```rust use std::env;
use deadpoolpostgres::{Manager, Pool}; use tokiopostgres::{Config, NoTls};
fn main() { let mut cfg = Config::new(); cfg.host("/var/run/postgresql"); cfg.user(env::var("USER").unwrap().as_str()); cfg.dbname("deadpool"); let mgr = Manager::new(cfg, NoTls); let pool = Pool::new(mgr, 16); loop { let mut client = pool.get().await.unwrap(); let stmt = client.prepare("SELECT random()").await.unwrap(); let rows = client.query(&stmt, &[]).await.unwrap(); let value: f64 = rows[0].get(0); println!("{}", value); } } ```
Licensed under either of
at your option.