rusqlite support library for the r2d2 connection pool.
BEWARE: Not related to r2d2_sqlite nor r2d2-sqlite3 crates (Jul 5, 2015 vs Jul 22, 2015).
use std::sync::Arc;
use std::thread;
use std::default::Default;
use r2d2::Pool;
use r2d2_sqlite::SQLiteConnectionManager;
use rusqlite::OpenFlags;
fn main() {
let manager = SQLiteConnectionManager::new("sample.db",
OpenFlags::SQLITE_OPEN_READ_WRITE);
let pool = Arc::new(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();
});
}
}