Module pool

Module pool 

Expand description

Provides the connection pool for asynchronous SQLz connections.

Opening a database connection for each and every operation to the database can quickly become expensive. Furthermore, sharing a database connection between threads and functions can be difficult to express in Rust.

A connection pool is a standard technique that can manage opening and re-using connections. Normally it also enforces a maximum number of connections as these are an expensive resource on the database server.

SQLz provides a canonical connection pool implementation intended to satisfy the majority of use cases.

See Pool for details.

Type aliases are provided for each database to make it easier to sprinkle Pool through your codebase:

§Opening a connection pool

A new connection pool with a default configuration can be created by supplying Pool with the database driver and a connection string.

use sqlz::mssql::MsSqlPool;

let pool = MsSqlPool::connect("mssql://").await?;

§Using a connection pool

A connection pool implements Executor and can be used directly when executing a query. Notice that only an immutable reference (&Pool) is needed.

sqlz::mssql::query("DELETE FROM articles").execute(&pool).await?;

A connection or transaction may also be manually acquired with Pool::acquire or Pool::begin.

Structs§

CloseEvent
A future that resolves when the pool is closed.
Pool
An asynchronous pool of SQLz database connections.
PoolConnection
A connection managed by a Pool.
PoolConnectionMetadata
Metadata for the connection being processed by a PoolOptions callback.
PoolOptions
Configuration options for Pool.