#async #database #pool #postgres

deadpool-postgres

Dead simple async pool for tokio-postgres

15 unstable releases (3 breaking)

✓ Uses Rust 2018 edition

0.5.5 Feb 28, 2020
0.5.4 Jan 26, 2020
0.4.3 Jan 10, 2020
0.4.2 Dec 31, 2019
0.2.1 Nov 18, 2019

#114 in Database interfaces

Download history 1095/week @ 2020-02-06 900/week @ 2020-02-13 833/week @ 2020-02-20 974/week @ 2020-02-27 847/week @ 2020-03-05 592/week @ 2020-03-12 643/week @ 2020-03-19 674/week @ 2020-03-26 682/week @ 2020-04-02 523/week @ 2020-04-09 470/week @ 2020-04-16 538/week @ 2020-04-23 656/week @ 2020-04-30 503/week @ 2020-05-07 591/week @ 2020-05-14 415/week @ 2020-05-21

3,046 downloads per month
Used in 3 crates (2 directly)

MIT/Apache

68KB
1K SLoC

Rust 571 SLoC // 0.4% comments Ruby HTML 431 SLoC // 0.3% comments Python 26 SLoC Shell 23 SLoC

Deadpool for PostgreSQL Latest Version

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

This crate implements a deadpool manager for tokio-postgres and also provides a statement cache by wrapping tokio_postgres::Client and tokio_postgres::Transaction.

Features

Feature Description Extra dependencies Default
config Enable support for config crate config, serde/derive yes

Example

use deadpool_postgres::{Config, Manager, Pool};
use tokio_postgres::{NoTls};

#[tokio::main]
async fn main() {
    let mut cfg = Config::from_env("PG").unwrap();
    let pool = cfg.create_pool(NoTls).unwrap();
    for i in 1..10 {
        let mut client = pool.get().await.unwrap();
        let stmt = client.prepare("SELECT 1 + $1").await.unwrap();
        let rows = client.query(&stmt, &[&i]).await.unwrap();
        let value: i32 = rows[0].get(0);
        assert_eq!(value, i + 1);
    }
}

License

Licensed under either of

at your option.

Dependencies

~7.5MB
~156K SLoC