#sqlite #r2d2 #pool

r2d2-sqlite3

Sqlite support for the r2d2 connection pool

2 releases

Uses old Rust 2015

0.1.1 Mar 6, 2018
0.1.0 Oct 10, 2017

#2332 in Database interfaces

47 downloads per month
Used in 4 crates (via sqlite3builder)

MIT license

4KB

r2d2-sqlite3

r2d2 connection pool for sqlite.

Using sqlite as the backend.


lib.rs:

Sqlite support for the r2d2 connection pool.

Library crate: r2d2-sqlite

Integrated with: r2d2 and rusqlite

Example

extern crate r2d2;
extern crate r2d2_sqlite3;
extern crate sqlite3;

use std::thread;
use r2d2_sqlite3::SqliteConnectionManager;

fn main() {
    let manager = SqliteConnectionManager::file("file.db");
    let pool = r2d2::Pool::builder().build(manager).unwrap();

    for i in 0..10i32 {
        let pool = pool.clone();
        thread::spawn(move || {
            let conn = pool.get().unwrap();
            let mut stmt = conn.prepare("INSERT INTO foo (bar) VALUES (?)").unwrap();
            stmt.bind(1, 42).unwrap();
        });
    }
}

Dependencies

~0.6–6.5MB
~16K SLoC