#postgres #sql #pool #database

r2d2_postgres

Postgres support for the r2d2 connection pool

29 releases (17 breaking)

0.18.1 Aug 16, 2021
0.18.0 Dec 25, 2020
0.17.0 Dec 19, 2020
0.16.0 Dec 24, 2019
0.1.0 Nov 24, 2014

#919 in Database interfaces

Download history 2095/week @ 2022-04-20 2273/week @ 2022-04-27 2691/week @ 2022-05-04 2623/week @ 2022-05-11 2349/week @ 2022-05-18 2478/week @ 2022-05-25 2619/week @ 2022-06-01 2334/week @ 2022-06-08 2210/week @ 2022-06-15 2203/week @ 2022-06-22 1990/week @ 2022-06-29 2061/week @ 2022-07-06 2308/week @ 2022-07-13 2084/week @ 2022-07-20 2382/week @ 2022-07-27 3405/week @ 2022-08-03

10,709 downloads per month
Used in fewer than 26 crates

MIT license

4KB

r2d2-postgres

CircleCI

Documentation

rust-postgres support library for the r2d2 connection pool.

Example

use std::thread;
use r2d2_postgres::{postgres::NoTls, PostgresConnectionManager};

fn main() {
    let manager = PostgresConnectionManager::new(
        "host=localhost user=postgres".parse().unwrap(),
        NoTls,
    );
    let pool = r2d2::Pool::new(manager).unwrap();

    for i in 0..10i32 {
        let pool = pool.clone();
        thread::spawn(move || {
            let mut client = pool.get().unwrap();
            client.execute("INSERT INTO foo (bar) VALUES ($1)", &[&i]).unwrap();
        });
    }
}

lib.rs:

Postgres support for the r2d2 connection pool.

Dependencies

~7–13MB
~251K SLoC