Skip to content

Pool

A connection pool for managing database connections.

__init__(pool, query_assembler=None)

Initialize a new connection pool.

Parameters:

Name Type Description Default
pool Pool

The asyncpg pool to use.

required
query_assembler QueryAssembler | None None

acquire() async

Acquire a connection from the pool.

Yields:

Type Description
AsyncGenerator[Connection]

A fassung.connection.Connection to the database.

from_connection_string(connection_string, *, min_size=10, max_size=10, max_queries=50000, max_inactive_connection_lifetime=300.0, host=None, port=None, user=None, password=None, passfile=None, database=None, query_assembler=None) async staticmethod

Convinience function to create a new connection pool.

Parameters:

Name Type Description Default
connection_string str

The connection string to use.

required
min_size int

The minimum number of connections in the pool.

10
max_size int

The maximum number of connections in the pool.

10
max_queries int

The maximum number of queries to execute before closing a connection.

50000
max_inactive_connection_lifetime float

The maximum time a connection can be inactive before being closed.

300.0
host str | None

The host to connect to.

None
port int | None

The port to connect to.

None
user str | None

The user to connect as.

None
password str | None

The password to use for authentication.

None
passfile str | None

The path to the password file.

None
database str | None

The database to connect to.

None
query_assembler QueryAssembler | None None