pub struct PoolOptions<DB> where
    DB: Database
{ /* private fields */ }

Implementations

Set the maximum number of connections that this pool should maintain.

Set the amount of time to attempt connecting to the database.

If this timeout elapses, Pool::acquire will return an error.

Set the minimum number of connections to maintain at all times.

When the pool is built, this many connections will be automatically spun up.

If any connection is reaped by max_lifetime or idle_timeout and it brings the connection count below this amount, a new connection will be opened to replace it.

Set the maximum lifetime of individual connections.

Any connection with a lifetime greater than this will be closed.

When set to None, all connections live until either reaped by idle_timeout or explicitly disconnected.

Infinite connections are not recommended due to the unfortunate reality of memory/resource leaks on the database-side. It is better to retire connections periodically (even if only once daily) to allow the database the opportunity to clean up data structures (parse trees, query metadata caches, thread-local storage, etc.) that are associated with a session.

Set a maximum idle duration for individual connections.

Any connection with an idle duration longer than this will be closed.

For usage-based database server billing, this can be a cost saver.

If true, the health of a connection will be verified by a call to Connection::ping before returning the connection.

Defaults to true.

Perform an action after connecting to the database.

Example
use sqlx_core::executor::Executor;
use sqlx_core::postgres::PgPoolOptions;
// PostgreSQL
let pool = PgPoolOptions::new()
    .after_connect(|conn| Box::pin(async move {
       conn.execute("SET application_name = 'your_app';").await?;
       conn.execute("SET search_path = 'my_schema';").await?;

       Ok(())
    }))
    .connect("postgres:// ā€¦").await?;

Creates a new pool from this configuration and immediately establishes one connection.

Creates a new pool from this configuration and immediately establishes one connection.

Creates a new pool from this configuration and will establish a connections as the pool starts to be used.

Creates a new pool from this configuration and will establish a connections as the pool starts to be used.

Trait Implementations

Formats the value using the given formatter. Read more

Returns the ā€œdefault valueā€ for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.