I am able to connect to DB2 just fine with my TOAD application however I need to be able to connect within python to build some automated reports.
I have installed the ibm_db library and I am trying to follow the instructions but I keep getting error SQLCODE=-30081.
import ibm_db
conn_str = 'database=XXXX;hostname=XXXX.host.com;port=11111;protocol=tcpip;uid=user;pwd=password'
conn = ibm_db_conn = ibm_db.connect(conn_str,'','')
Traceback:
Traceback (most recent call last):
File "C:/Users/username/PycharmProjects/Report/MAIN/MAIN.py", line 4, in <module>
conn = ibm_db_conn = ibm_db.connect(conn_str,'','')
SQLCODE=-30081
Looking up -30081 is not very helpful as it can be caused by a list of things.
I did read somewhere that maybe ibm_db is only supported on Python 3.4 and I am using Python 3.6 however I cannot install Python 3.4 on my work PC right now as its admin locked.
Update:
Tested connection using the command line with the 2 different connections options available to ibm_db.
Both connections types:
import ibm_db
conn_str = 'database=XXXX;hostname=111.111.111.111;port=11111;protocol=tcpip;uid=username;pwd=password'
try:
conn = ibm_db.connect(conn_str, '', '')
except:
print("no connection:", ibm_db.conn_errormsg())
else:
print("The 1st connection was successful")
try:
conn = ibm_db.connect('XXXX', 'username', 'password')
except:
print("no connection:", ibm_db.conn_errormsg())
else:
print("The 2nd connection was successful")
Error:
C:\Users\username\Desktop\Python 3.6.2>python test.py
no connection: [IBM][CLI Driver] SQL30081N A communication error has been detected. Communication protocol being used: "TCP/IP". Communication API being used: "SOCKETS". Location where the error was detected: "111.111.111.111". Communica SQLCODE=-30081etecting the error: "recv". Protocol specific error code(s): "10054", "*", "0". SQLSTATE=08001
no connection: [IBM][CLI Driver] SQL30082N Security processing failed with reason "19" ("USERID DISABLED or RESTRICTED" SQLCODE=-30082001
Any guidance would be appreciated.