Top
Enterprise Postgres 17 SP1 Connection Manager User's Guide

3.6 How to Use in Python Language Package (psycopg)

Describes points to note when using the Connection Manager using the Python language package (psycopg).

In the Python language package (psycopg), you can use the psycopg.Connection class and the psycopg.AsyncConnection class to work with the Connection Manager. If you want to use methods that are not defined in these two classes, also refer to "3.3 How to Use in libpq".

The Connection Manager's heartbeat monitoring feature cannot be used with the Python language package (psycopg). Therefore, if you want to perform heartbeat monitoring with the Python language package (psycopg), use the TCP keepalive feature. However, the TCP keepalive feature has disadvantages, as listed in "1.1.1 Difference from TCP keepalive". Deal with this as follows.

Regarding the problem that keepalive does not work when the TCP layer does not receive an acknowledgement (ACK) from the other side and the packet is repeatedly retransmitted:

Set the tcp_user_timeout parameter. Since the Python language package (psycopg) communicates using libpq, you can use the tcp_user_timeout parameter of libpq.

A problem where network load is heavy due to periodic packets being sent on a per-TCP socket basis for keepalive:

There is no workaround because the keepalive feature needs to be enabled. Therefore, be careful when using the Python language package (psycopg) directly.