Db2 connection from Python using ibm_db

Ever watch the Web Console or a list of connections to the the database and wondered who or what was "db2jcc_application"?

I Just discovered how to set connection options using ibm_db connections and put my  applications name in so it shows in the application lists.


here's a code example

options on connections
1
2
3
4
5
6
7
8
9
   try:
       options3 = {ibm_db.SQL_ATTR_INFO_PROGRAMNAME : 'pyHelmAgent',ibm_db.SQL_ATTR_INFO_APPLNAME: 'pyHelmAgent'}
       conn_str='database=bludb;hostname='+creds.chostname+';port=50000;protocol=tcpip;uid='+creds.conuser+';pwd='+creds.conpasswd
       ibm_db_conn = ibm_db.connect(conn_str,'','',options3)
   except Exception as e:i
       root.exception('Connection Error occurred')
 
 
<ibm_db.IBM_DBStatement object at 0x0000020BD5EF42D0>APP_HANDL:3347, APPLICATION_NAME:pyHelmAgent, APPLICATION_ID:127.0.0.1.57780.220526140556, MEMBER:019163



Here's a link to other possibilities

https://github.com/ibmdb/python-ibmdb/wiki/APIs#ibm_dbconnect

scroll down and the example sets options.  Nice!  AUTOCOMMIT?  CLIENT, etc.

Comments