psycopg_pool - Connection pool implementations - psycopg 3.1.9 documentation
Psycopg - PostgreSQL database adapter for Python - Psycopg documentation
- Connection pool implementations
A connection pool is an object used to create and maintain a limited amount of PostgreSQL connections, reducing the time requested by the program to obtain a working connection and allowing an arbitrary large number of concurrent threads or tasks to use a controlled amount of resources on the server. See Connection pools for more details and usage pattern.
This package exposes a few connection pool classes:
ConnectionPoolis a synchronous connection pool yielding
Connectionobjects and can be used by multithread applications.
ConnectionPoolsubclass exposing the same interface of its parent, but not keeping any unused connection in its state. See Null connection pools for details about related use cases.
AsyncNullConnectionPoolhas the same behaviour of the
NullConnectionPool, but with the same async interface of the
package is distributed separately from the main
, to make it available. See
Installing the connection pool
The version numbers indicated in this page refer to the
package, not to
Pool exceptions #
has a very similar interface to the
class but its blocking methods are implemented as
returns instances of
, or of its subclass if
specified so in the
Only the functions with different signature from
Null connection pools #
New in version 3.1.
subclass which doesn’t create
connections preemptively and doesn’t keep unused connections in its state. See
Null connection pools
for further details.
The interface of the object is entirely compatible with its parent class. Its behaviour is similar, with the following differences:
is, similarly, an
with the same behaviour of the