Input parameters to ibm_db.connect and ibm_db_dbi.connect - SQL_ATTR_INFO_PROGRAMNAME

1,080 views
Skip to first unread message

Jim Fletcher

unread,
Jan 18, 2016, 11:13:56 PM1/18/16
to ibm_db
I'm new to Python DB2 programming so forgive me in advance :)

I'm trying to set the SQL_ATTR_INFO_PROGRAMNAME to display 'myapp' instead of 'python.exe' in the db2 list applications output.
This code works fine:

import ibm_db

import ibm_db_dbi

opt={ibm_db.SQL_ATTR_INFO_PROGRAMNAME : 'myapp'}

cn=ibm_db_dbi.connect('SAMPLE','db2admin','******',conn_options=opt)

#cn.close()

# cn.close()


However I don't want to use ibm_db_dbi.connect and would prefer to use ibm_db.connect. I can't find documentation on ibm_db.connect properties, or what I can pass as input parms, in this case conn_options. So I have really 2 questions:

1. How can I set SQL_ATTR_PROGRAMNAME to 'myapp' using ibm_db.connect?

2. How can I find the available input parameters tor methods/functions to either ibm_db or ibm_db_dbi? I've tried dir() in python, which lists methods but not properties/input parms, and searched the IBM and Python doc and can't find official doc, just sample code that others are used or samples in the IBM doc. 


If my thinking is wrong (which is usually the case) please correct. Having 2 different modules to use is confusing. 

Thank you.

roopa.ra...@in.ibm.com

unread,
Jan 18, 2016, 11:24:09 PM1/18/16
to ibm_db
HI Jim,

1) You can use ibm_db.connect and set SQL_ATTR_PROGRAMNAME like below .

import ibm_db


options1 = {ibm_db.SQL_ATTR_INFO_PROGRAMNAME: 'myapp'}
conn1 = ibm_db.connect('stlec1','sysadm', '*****' , options1)
print "Connection successful"
val = ibm_db.get_option(conn1, ibm_db.SQL_ATTR_INFO_PROGRAMNAME, 1)
print val


2) To find more available inputs on existing APIs  to ibm_db you can refer to this link

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


Please let us know in case of further queries

Jim Fletcher

unread,
Jan 20, 2016, 9:53:06 PM1/20/16
to ibm_db
Thanks very much Roopa. This info is very helpful.
Reply all
Reply to author
Forward
0 new messages