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 34911/week @ 2025-07-19 36298/week @ 2025-07-26 31497/week @ 2025-08-02 42881/week @ 2025-08-09 39491/week @ 2025-08-16 67407/week @ 2025-08-23 69107/week @ 2025-08-30 229388/week @ 2025-09-06 34967/week @ 2025-09-13 29456/week @ 2025-09-20 31728/week @ 2025-09-27 31640/week @ 2025-10-04 31798/week @ 2025-10-11 33330/week @ 2025-10-18 35941/week @ 2025-10-25 31286/week @ 2025-11-01

138,828 downloads per month
Used in 137 crates (83 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