Crates.io | r2d2_postgres |
lib.rs | r2d2_postgres |
version | 0.18.1 |
source | src |
created_at | 2014-11-24 02:37:43.83886 |
updated_at | 2021-08-16 14:52:31.059889 |
description | Postgres support for the r2d2 connection pool |
homepage | |
repository | https://github.com/sfackler/r2d2-postgres |
max_upload_size | |
id | 383 |
size | 6,340 |
rust-postgres support library for the r2d2 connection pool.
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();
});
}
}