Crate deadpool_sqlite[][src]

Expand description

Deadpool for PostgreSQL Latest Version

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

This crate implements a deadpool manager for tokio-postgres and also provides a statement cache by wrapping tokio_postgres::Client and tokio_postgres::Transaction.

Features

FeatureDescriptionExtra dependenciesDefault
configEnable support for config crateconfig, serde/deriveyes

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

Structs

Config

Configuration object. By enabling the config feature you can read the configuration using the config crate.

ConnectionWrapper

A wrapper for rusqlite::Connection which provides indirect access to it via the interact function.

Manager

The manager for creating and recyling SQLite connections

PoolConfig

Re-export deadpool::managed::PoolConfig

Enums

Runtime

Re-export deadpool::Runtime;

Type Definitions

Connection

A type alias for using deadpool::Object with rusqlite

Pool

A type alias for using deadpool::Pool with rusqlite

PoolError

A type alias for using deadpool::PoolError with rusqlite