multitool_hg::database::postgres

Function new_postgres_pool

source
pub async fn new_postgres_pool(config: DatabaseConfig) -> Result<PgPool, Error>
Expand description

Creates a new PostgreSQL connection pool using the provided DatabaseConfig.

This function establishes a connection pool with the PostgreSQL database based on the parameters in the DatabaseConfig struct. It allows you to configure the number of connections, timeouts, and connection lifetime.

§Parameters

  • config: A DatabaseConfig struct containing the necessary details for connecting to the PostgreSQL database, such as host, port, username, password, etc.

§Returns

A Result containing either a PgPool on success or an anyhow::Error on failure.

§Errors

This function returns an error if the connection to the database cannot be established, or if the connection pool options are invalid.