Frank_Sma
Frank_Sma

Reputation: 37

Python package IBM_DB connection with enableAlternateServerListFirstConnect and alternateserverlist parameters

I have a requirement to enable a failover/secondary database for a DB2 database hosted on a Linux Server for a python application using the IBM_DB package.

With a JDBC driver, you can easily the following parameters to the connection string:

clientRerouteAlternatePortNumber=port#
clientRerouteAlternateServerName=servername
enableSeamlessFailover=1 

Since the IBM_DB package uses a CLI driver, these parameters wouldn't be the same. I found the following parameters through the IBM documentation, which are: https://www.ibm.com/support/knowledgecenter/SSEPGG_11.5.0/com.ibm.db2.luw.apdv.embed.doc/doc/c0060428.html

enableAlternateServerListFirstConnect
alternateserverlist
maxAcrRetries

However, through the instructions of how to include it in the link below, it seems like it is only possible to include them in this DB file: db2dsdriver.cfg

https://www.ibm.com/support/producthub/db2/docs/content/SSEPGG_11.5.0/com.ibm.db2.luw.apdv.cli.doc/doc/c0056196.html

I know a lot of these parameters are configurable in the connection string, and I wanted to know if it was possible to include these particular parameters in the connection string. Is there any documentation/verification that something like this can work:

import ibm_db_dbi

connect = ibm_db_dbi.connect("DATABASE=whatever; \
    HOSTNAME=whatever; \
    PORT=whatever; \
    PROTOCOL=TCPIP; \
    UID=whatever; \
    PWD=whatever; \
    CURRENTSCHEMA=whatever;\
    AUTHENTICATION=SERVER_ENCRYPT;\
    ClientEncAlg=2;\
    enableAlternateServerListFirstConnect=True;\
    alternateserverlist=server1,port1,server2,port2;\
    maxAcrRetries=2", "", "")

Thank you for any help.

Upvotes: 0

Views: 601

Answers (1)

mao
mao

Reputation: 12287

A helpful page to is this one.

Note the different names of keywords/parameters between jdbc/sqlj and CLI.

The idea is that with the CLI driver, if the Db2-LUW instance is properly configured, then the CLI driver will get the details of ACR from the Db2-LUW-instance automatically and useful defaults will apply . So you might not need to add more keywords in the connection string, unless tuning.

The HA related keyword parameters for CLI are below :

acrRetryInterval
alternateserverlist
detectReadonlyTxn
enableAcr
enableAlternateGroupSeamlessACR
enableAlternateServerListFirstConnect
enableSeamlessAcr
maxAcrRetries

More details here. Note that if enableACR=true ( the default ) then enableSeamlessAcr=true (also default).

Although the docs mention db2dsdriver.cfg most CLI parameter/keywords are also settable in the connection string, unless specifically excluded. So do your testing to verify.

Upvotes: 1

Related Questions