9 releases (breaking)

0.8.0 Mar 31, 2024
0.7.0 Nov 14, 2023
0.6.0 Sep 26, 2023
0.5.0 Jul 18, 2022
0.1.0 May 30, 2021

#1157 in Database interfaces

Download history 722/week @ 2023-12-22 843/week @ 2023-12-29 1523/week @ 2024-01-05 2017/week @ 2024-01-12 1914/week @ 2024-01-19 2441/week @ 2024-01-26 2101/week @ 2024-02-02 2110/week @ 2024-02-09 1536/week @ 2024-02-16 1714/week @ 2024-02-23 2017/week @ 2024-03-01 1910/week @ 2024-03-08 2149/week @ 2024-03-15 2051/week @ 2024-03-22 2002/week @ 2024-03-29 2199/week @ 2024-04-05

8,728 downloads per month
Used in 19 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

~23–37MB
~556K SLoC