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 |
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
- 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;
Structs§
- Config
- Configuration object.
- Manager
Manager
for creating and recycling SQLiteConnection
s.- Metrics
- Statistics regarding an object returned by the pool
- Pool
Config Pool
configuration.- Status
- The current pool status.
- Sync
Guard - This guard is returned when calling
SyncWrapper::lock
orSyncWrapper::try_lock
. This is basicly just a wrapper around aMutexGuard
but hides some implementation details. - Timeouts
- Timeouts when getting
Object
s from aPool
.
Enums§
- Interact
Error - Possible errors returned when
SyncWrapper::interact()
fails. - Runtime
- Enumeration for picking a runtime implementation.
Type Aliases§
- Build
Error - Type alias for using
deadpool::managed::BuildError
withrusqlite
. - Config
Error - This error is returned if there is something wrong with the SQLite configuration.
- Connection
- Type alias for
Object
- Create
Pool Error - Type alias for using
deadpool::managed::CreatePoolError
withrusqlite
. - Hook
- Type alias for using
deadpool::managed::Hook
withrusqlite
. - Hook
Error - Type alias for using
deadpool::managed::HookError
withrusqlite
. - Object
- Type alias for using
deadpool::managed::Object
withrusqlite
. - Pool
- Type alias for using
deadpool::managed::Pool
withrusqlite
. - Pool
Builder - Type alias for using
deadpool::managed::PoolBuilder
withrusqlite
. - Pool
Error - Type alias for using
deadpool::managed::PoolError
withrusqlite
.