11 releases (breaking)

0.9.0 Oct 24, 2024
0.8.1 May 14, 2024
0.8.0 Mar 31, 2024
0.7.0 Nov 14, 2023
0.1.0 May 30, 2021

#1735 in Database interfaces

Download history 2250/week @ 2024-07-25 1585/week @ 2024-08-01 1351/week @ 2024-08-08 1196/week @ 2024-08-15 1252/week @ 2024-08-22 1770/week @ 2024-08-29 1461/week @ 2024-09-05 1629/week @ 2024-09-12 1671/week @ 2024-09-19 1690/week @ 2024-09-26 1745/week @ 2024-10-03 1838/week @ 2024-10-10 1746/week @ 2024-10-17 1510/week @ 2024-10-24 2169/week @ 2024-10-31 1667/week @ 2024-11-07

7,482 downloads per month
Used in 21 crates (10 directly)

MIT/Apache

92KB
1.5K SLoC

Deadpool for SQLite Latest Version Unsafe forbidden Rust 1.75+

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

~24–34MB
~557K SLoC