Crate deadpool_sqlite
source · [−]Expand description
Deadpool for SQLite

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 |
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
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Re-exports
pub use rusqlite;Macros
This macro creates all the type aliases usually reexported by
deadpool-* crates. Crates that implement a deadpool manager should
be considered stand alone crates and users of it should not need
to use deadpool directly.
Structs
Configuration object.
Manager for creating and recycling SQLite Connections.
Statistics regarding an object returned by the pool
Pool configuration.
The current pool status.
This guard is returned when calling SyncWrapper::lock or
SyncWrapper::try_lock. This is basicly just a wrapper around
a MutexGuard but hides some implementation details.
Enums
Possible errors returned when SyncWrapper::interact() fails.
Enumeration for picking a runtime implementation.
Type Definitions
Type alias for using deadpool::managed::BuildError with rusqlite.
This error is returned if there is something wrong with the SQLite configuration.
Type alias for Object
Type alias for using deadpool::managed::CreatePoolError with rusqlite.
Type alias for using deadpool::managed::Hook with rusqlite.
Type alias for using deadpool::managed::HookError with rusqlite.
Type alias for using deadpool::managed::HookErrorCause with rusqlite.
Type alias for using deadpool::managed::Object with rusqlite.
Type alias for using deadpool::managed::Pool with rusqlite.
Type alias for using deadpool::managed::PoolBuilder with rusqlite.
Type alias for using deadpool::managed::PoolError with rusqlite.