No description, website, or topics provided.
Clone or download
Latest commit 8fe0923 Nov 28, 2017
Permalink
Failed to load latest commit information.
.circleci Update circle config Nov 26, 2017
src Release 0.14.0 Nov 26, 2017
tests Update to r2d2 0.8 Nov 26, 2017
.gitignore Add PostgresPoolManager Aug 6, 2014
Cargo.toml Release 0.14.0 Nov 26, 2017
LICENSE Initial commit Aug 6, 2014
README.md Fix README example Nov 28, 2017

README.md

r2d2-postgres

CircleCI

Documentation

rust-postgres support library for the r2d2 connection pool.

Example

extern crate r2d2;
extern crate r2d2_postgres;
extern crate postgres;

use std::thread;
use r2d2_postgres::{TlsMode, PostgresConnectionManager};

fn main() {
    let manager = PostgresConnectionManager::new("postgres://postgres@localhost",
                                                 TlsMode::None).unwrap();
    let pool = r2d2::Pool::new(manager).unwrap();

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