1 unstable release

0.1.0 May 30, 2021

#37 in #sqlite

MIT/Apache

64KB
915 lines

Deadpool for SQLite Latest Version

Deadpool is a dead simple async pool for connections and objects of any type.

This crate implements a deadpool manager for rusqlite and provides a wrapper that ensures correct use of the connection inside a separate thread.

Features

Feature Description Extra dependencies Default
config Enable support for config crate config, serde/derive yes

Example

use deadpool_sqlite::Config;

#[tokio::main]
async fn main() {
    let mut cfg = Config::new("db.sqlite3");
    let pool = cfg.create_pool();
    for i in 1..10 {
        let mut conn = pool.get().await.unwrap();
        let value: i32 = conn.interact(move |conn| {
            let mut stmt = conn.prepare_cached("SELECT 1 + $1").unwrap();
            stmt.query_row([&i], |row| row.get(0)).unwrap()
        }).await;
        assert_eq!(value, i + 1);
    }
}

License

Licensed under either of

at your option.

Dependencies

~15MB
~296K SLoC