#postgresql #connection-pool #pool #sql

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

#1413 in Database interfaces

Download history 3004/week @ 2024-03-14 3280/week @ 2024-03-21 3327/week @ 2024-03-28 2894/week @ 2024-04-04 2518/week @ 2024-04-11 2632/week @ 2024-04-18 2639/week @ 2024-04-25 2601/week @ 2024-05-02 2337/week @ 2024-05-09 3440/week @ 2024-05-16 2571/week @ 2024-05-23 2423/week @ 2024-05-30 3358/week @ 2024-06-06 3124/week @ 2024-06-13 3133/week @ 2024-06-20 2050/week @ 2024-06-27

12,038 downloads per month
Used in 49 crates (35 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

~7–17MB
~236K SLoC