2个不稳定版本

0.18.0 2021年10月4日
0.1.0 2023年4月24日

#2609数据库接口

Download history 456/week @ 2024-03-13 874/week @ 2024-03-20 382/week @ 2024-03-27 599/week @ 2024-04-03 612/week @ 2024-04-10 754/week @ 2024-04-17 990/week @ 2024-04-24 745/week @ 2024-05-01 645/week @ 2024-05-08 764/week @ 2024-05-15 812/week @ 2024-05-22 1221/week @ 2024-05-29 850/week @ 2024-06-05 511/week @ 2024-06-12 583/week @ 2024-06-19 469/week @ 2024-06-26

2,585 每月下载量
24 个crate中使用 (通过 holochain_sqlite)

MIT 许可证

8KB
83 代码行

r2d2-sqlite

Latest Version Build Status MIT licensed

r2d2连接池,基于Steven Fackler的r2d2-postgres。

文档


lib.rs:

为r2d2连接池提供Sqlite支持。

库crate: r2d2-sqlite

集成: r2d2rusqlite

示例

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()
}

依赖项

~28MB
~443K SLoC