pub struct SqlitePool { /* private fields */ }Expand description
A connection pool for SQLite.
This pool provides connection reuse for file-based SQLite databases, significantly improving performance by avoiding repeated connection opens.
§Example
use prax_sqlite::{SqlitePool, SqliteConfig};
let pool = SqlitePool::new(SqliteConfig::file("data.db")).await?;
let conn = pool.get().await?;
// Use connection...
// Connection is returned to pool when droppedImplementations§
Source§impl SqlitePool
impl SqlitePool
Sourcepub async fn new(config: SqliteConfig) -> SqliteResult<Self>
pub async fn new(config: SqliteConfig) -> SqliteResult<Self>
Create a new connection pool from configuration.
Sourcepub async fn with_pool_config(
config: SqliteConfig,
pool_config: PoolConfig,
) -> SqliteResult<Self>
pub async fn with_pool_config( config: SqliteConfig, pool_config: PoolConfig, ) -> SqliteResult<Self>
Create a new connection pool with custom pool configuration.
Sourcepub async fn get(&self) -> SqliteResult<SqliteConnection>
pub async fn get(&self) -> SqliteResult<SqliteConnection>
Get a connection from the pool.
For file-based databases, this will try to reuse an idle connection before opening a new one. For in-memory databases, always opens a new connection (since each connection has its own database).
Sourcepub fn config(&self) -> &SqliteConfig
pub fn config(&self) -> &SqliteConfig
Get the pool configuration.
Sourcepub fn pool_config(&self) -> &PoolConfig
pub fn pool_config(&self) -> &PoolConfig
Get the pool settings.
Sourcepub fn reset_stats(&self)
pub fn reset_stats(&self)
Reset pool statistics.
Sourcepub async fn is_healthy(&self) -> bool
pub async fn is_healthy(&self) -> bool
Check if the pool is healthy by attempting to get a connection.
Sourcepub fn available_permits(&self) -> usize
pub fn available_permits(&self) -> usize
Get the number of available permits (potential concurrent connections).
Sourcepub fn idle_count(&self) -> usize
pub fn idle_count(&self) -> usize
Get the number of idle connections in the pool.
Sourcepub fn builder() -> SqlitePoolBuilder
pub fn builder() -> SqlitePoolBuilder
Create a builder for configuring the pool.
Trait Implementations§
Source§impl Clone for SqlitePool
impl Clone for SqlitePool
Source§fn clone(&self) -> SqlitePool
fn clone(&self) -> SqlitePool
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more