Reputation: 6610
I can't connect to a DB2 remote server using Python. Here is what I've done:
sudo pip install ibm_db
Ran the following code:
import ibm_db
ibm_db.connect("my_connection_string", "", "")
I then get the following error:
Exception: [IBM][CLI Driver] SQL1042C An unexpected system error occurred. SQLSTATE=58004 SQLCODE=-1042
I've googled around for hours and trying out different solutions. Unfortunately, I haven't been able to find a proper guide for setting the environment up on Mac OS X + Python + DB2.
Upvotes: 1
Views: 3398
Reputation: 11
check your ibmdb connection parameters
conn=ibm_db.connect("DATABASE=dbname;HOSTNAME=hostname;PORT=32286;SECURITY=SSL;SSLSererCertificate=DigiCertGlobalRootCA.crt;UID=username;PWD=passwd",'','')
conn=ibm_db.connect("DATABASE=dbname;HOSTNAME=hostname;PORT=32286;SECURITY=SSL;SSLSererCertificate=DigiCertGlobalRootCA.crt;UID=username;PWD=passwd",'','')
Ensure that ssl certificate parameter --filename with extension SSLSererCertificate=DigiCertGlobalRootCA.crt
Upvotes: 0
Reputation: 9
We are able to install the driver successfully and connection to db is established without any problem.
The steps are: 1) Upgraded to OS X El Capitan 2) Install pip - sudo pip install 3) Install ibm_db - sudo pip install ibm_db 4) During installation, below error was hit
Referenced from: /Users/roramana/Library/Python/2.7/lib/python/site-packages/ibm_db.so Reason: unsafe use of relative rpath libdb2.dylib in /Users/roramana/Library/Python/2.7/lib/python/site-packages/ibm_db.so with restricted binary
After disabling the System Integrity Protection, installation went fine.
From the error sql1042c, it seems like you are hitting some environment setup issue. You could try setting DYLD_LIBRARY_PATH to the path where you have extracted the odbc and cli driver .
If the problem still persist, please collect db2 traces and share with us:
db2trc on -f trc.dmp
run your repro
db2trc off
db2trc flw trc.dmp trc.flw
db2trc fmt trc.dmp trc.fmt
Share the trc.flw and trc.fmt files.
Upvotes: 1
Reputation: 11
I was able to reproduce the error 1042C in one of the mac machine.
Solution for the same is to set DYLD_LIBRARY_PATH
to clidriver/lib/icc
. I would suggest you set DYLD_LIBRARY_PATH
to both clidriver/lib
and clidriver/lib/icc
For Eg:
export DYLD_LIBRARY_PATH=/Library/Python/2.7/site-packages/ibm_db-2.0.6-py2.7-macosx-10.10-intel.egg/clidriver/lib:/Library/Python/2.7/site-packages/ibm_db-2.0.6-py2.7-macosx-10.10-intel.egg/clidriver/lib/icc
I have python 2.7 installed in my machine and easy_install/pip install auto downloaded clidriver to /Library/Python/2.7/site-packages/ibm_db-2.0.6-py2.7-macosx-10.10-intel.egg/
directory.
Request you to set DYLD_LIBRARY_PATH
as per your environment. Please let us know whether it solves your problem.
Upvotes: 1
Reputation: 544
Have you followed the setup instructions here? https://www-01.ibm.com/support/knowledgecenter/SSEPGG_9.7.0/com.ibm.swg.im.dbclient.python.doc/doc/t0054368.html
You need your DB2 ODBC driver properly installed before your Python code will work.
This issue may also shed light: https://github.com/ibmdb/node-ibm_db/issues/34
Upvotes: 1