#postgresql #sql #pool

r2d2_postgres

Postgres support for the r2d2 connection pool

30 releases (17 breaking)

0.18.2 Dec 23, 2024
0.18.1 Aug 16, 2021
0.18.0 Dec 25, 2020
0.16.0 Dec 24, 2019
0.1.0 Nov 24, 2014

#597 in Database interfaces

Download history 1224/week @ 2024-12-21 1416/week @ 2024-12-28 2867/week @ 2025-01-04 2366/week @ 2025-01-11 2077/week @ 2025-01-18 1606/week @ 2025-01-25 2261/week @ 2025-02-01 2979/week @ 2025-02-08 2345/week @ 2025-02-15 2476/week @ 2025-02-22 2220/week @ 2025-03-01 2840/week @ 2025-03-08 3691/week @ 2025-03-15 3165/week @ 2025-03-22 2268/week @ 2025-03-29 2341/week @ 2025-04-05

12,005 downloads per month
Used in 50 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();
        });
    }
}

Dependencies

~8–17MB
~244K SLoC