【发布时间】:2023-02-08 23:23:20
【问题描述】:
Python/psycopg2/ThreadedConnectionPool 是否接受一个参数,告诉它只连接到 Postgres HA 集群中的主服务器?等效的 jdbc 连接字符串看起来像,注意目标服务器类型=主要:
jdbc:postgresql://serverName1:5432,serverName2:5432,serverName3:5432/dataBaseName?loadBalanceHosts=false&targetServerType=primary
如何在下面的连接设置中将 targetServerType 传递给 ThreadedConnectionPool:
self._pg_pool = psycopg2.pool.ThreadedConnectionPool(
minconn = 1,
maxconn = 2,
host = 'serverName1, serverName2, serverName3',
database = 'dataBaseName1',
user = 'userName',
password = 'passWord',
port = "5432",
application_name = 'MyTestApp'
)
【问题讨论】:
标签: python postgresql psycopg2