42 releases (breaking)

0.31.0 Jul 11, 2025
0.29.0 May 31, 2025
0.27.0 Mar 8, 2025
0.25.0 Jul 21, 2024
0.0.1 Jul 22, 2015

#39 in Database interfaces

Download history 35303/week @ 2025-07-15 33237/week @ 2025-07-22 34328/week @ 2025-07-29 34769/week @ 2025-08-05 44638/week @ 2025-08-12 43003/week @ 2025-08-19 79328/week @ 2025-08-26 104165/week @ 2025-09-02 179916/week @ 2025-09-09 31335/week @ 2025-09-16 30276/week @ 2025-09-23 30008/week @ 2025-09-30 32440/week @ 2025-10-07 34277/week @ 2025-10-14 33896/week @ 2025-10-21 27889/week @ 2025-10-28

133,369 downloads per month
Used in 136 crates (82 directly)

MIT license

10KB
102 lines

Sqlite support for the r2d2 connection pool.

Library crate: r2d2-sqlite

Integrated with: r2d2 and rusqlite

Example

extern crate r2d2;
extern crate r2d2_sqlite;
extern crate rusqlite;

use std::thread;
use r2d2_sqlite::SqliteConnectionManager;
use rusqlite::params;

fn main() {
    let manager = SqliteConnectionManager::file("file.db");
    let pool = r2d2::Pool::new(manager).unwrap();
    pool.get()
        .unwrap()
        .execute("CREATE TABLE IF NOT EXISTS foo (bar INTEGER)", params![])
        .unwrap();

    (0..10)
        .map(|i| {
            let pool = pool.clone();
            thread::spawn(move || {
                let conn = pool.get().unwrap();
                conn.execute("INSERT INTO foo (bar) VALUES (?)", &[&i])
                    .unwrap();
            })
        })
        .collect::<Vec<_>>()
        .into_iter()
        .map(thread::JoinHandle::join)
        .collect::<Result<_, _>>()
        .unwrap()
}

r2d2-sqlite

Latest Version Build Status MIT licensed

r2d2 connection pool for sqlite based on Steven Fackler's r2d2-postgres.

Documentation

Dependencies

~23MB
~445K SLoC