#postgres #sql #pool

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

#11 in #std-thread

Download history 3058/week @ 2023-11-06 2882/week @ 2023-11-13 2636/week @ 2023-11-20 2701/week @ 2023-11-27 2647/week @ 2023-12-04 3025/week @ 2023-12-11 3176/week @ 2023-12-18 2044/week @ 2023-12-25 2852/week @ 2024-01-01 3113/week @ 2024-01-08 3188/week @ 2024-01-15 2569/week @ 2024-01-22 3423/week @ 2024-01-29 2942/week @ 2024-02-05 2988/week @ 2024-02-12 3753/week @ 2024-02-19

13,272 downloads per month
Used in 47 crates (33 directly)

MIT license

5KB

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

~8–19MB
~319K SLoC