#async #pool #sqlite

deadpool-sqlite

Dead simple async pool for rusqlite

8 releases (breaking)

0.7.0 Nov 14, 2023
0.6.0 Sep 26, 2023
0.5.0 Jul 18, 2022
0.4.0 Apr 4, 2022
0.1.0 May 30, 2021

#1040 in Database interfaces

Download history 1119/week @ 2023-10-30 1217/week @ 2023-11-06 1484/week @ 2023-11-13 1360/week @ 2023-11-20 1148/week @ 2023-11-27 1512/week @ 2023-12-04 1499/week @ 2023-12-11 1708/week @ 2023-12-18 754/week @ 2023-12-25 1175/week @ 2024-01-01 1711/week @ 2024-01-08 1930/week @ 2024-01-15 2137/week @ 2024-01-22 2539/week @ 2024-01-29 2539/week @ 2024-02-05 1870/week @ 2024-02-12

9,148 downloads per month
Used in 12 crates (9 directly)

MIT/Apache

93KB
1.5K SLoC

Deadpool for SQLite Latest Version Unsafe forbidden Rust 1.63+

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
rt_tokio_1 Enable support for tokio crate deadpool/rt_tokio_1 yes
rt_async-std_1 Enable support for async-std crate deadpool/rt_async-std_1 no
serde Enable support for serde crate deadpool/serde, serde/derive no
tracing Enable support for tracing by propagating Spans in the interact() calls. Enable this if you use the tracing crate and you want to get useful traces from within interact() calls. deadpool-sync/tracing, tracing no

Example

use deadpool_sqlite::{Config, Runtime};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut cfg = Config::new("db.sqlite3");
    let pool = cfg.create_pool(Runtime::Tokio1).unwrap();
    let conn = pool.get().await.unwrap();
    let result: i64 = conn
        .interact(|conn| {
            let mut stmt = conn.prepare("SELECT 1")?;
            let mut rows = stmt.query([])?;
            let row = rows.next()?.unwrap();
            row.get(0)
        })
        .await??;
    assert_eq!(result, 1);
    Ok(())
}

License

Licensed under either of

at your option.

Dependencies

~23–36MB
~563K SLoC