No longer able to find db2dsdriver.cfg [Python]

1,997 views
Skip to first unread message

Stephen Tanner

unread,
May 27, 2015, 1:38:42 PM5/27/15
to ibm...@googlegroups.com
It seems that after updating to the latest ibm-db release (2.0.5.1) via pip, I am no longer able to connect to our DB2 instance.

Attempting a connection manually in iPython yields this error message:

Error: ibm_db_dbi::Error: [IBM][CLI Driver] SQL1531N  The connection failed because the name specified with the DSN connection string keyword could not be found in either the db2dsdriver.cfg configuration file or the db2cli.ini configuration file.  Data source name specified in the connection string: "<DSN ALIAS>". SQLCODE=-1531

I am running Archlinux (where it is broken) and on my docker images which are Ubuntu it still works just fine.

I have tried reinstalling the dsdriver and ibm-db package.

I would revert to a previous version of the ibm-db package but specifying ==2.0.5 w/ pip just fails w/ an empty tar.gz

Is there a way I can get the ibm-db driver to spit out where it thinks the file is and why it thinks it can no longer recognize the contents on only my system?

Rahul

unread,
May 27, 2015, 1:57:10 PM5/27/15
to ibm...@googlegroups.com, ste...@stephentanner.com
Hi Stephen,
  If you don't set IBM_DB_HOME environment variable before doing pip install, ibm_db will download and install a local copy of  Data Server Driver instead of throwing error to install DS Driver and set IBM_DB_HOME directory.

In your case since you are upgrading ibm_db driver you should have DS Driver or CLI thick client, then Please set IBM_DB_HOME to correct location uninstall ibm_db and reinstall it through pip install.

Please let me know if your issue still persist.

Thanks,
Rahul

Stephen Tanner

unread,
May 28, 2015, 1:54:03 AM5/28/15
to ibm...@googlegroups.com, ste...@stephentanner.com

I already have the DSdriver installed and I went ahead and resinstalled it.

echo $IBM_DB_HOME shows the correct path to the dsdriver folder

So if I uninstall the ibm-db package, then reinstall ibm-db via pip with the IBM_DB_HOME envvar not set, pip should install the dsdriver package from IBM for me? This does not seem right but ill try it.

I may just fire up strace and see if the driver is even looking for the right file.

Is there a part of the imb-db source you could point me to where it actually calls fopen then reads the config file?

Stephen Tanner

unread,
May 28, 2015, 1:54:03 AM5/28/15
to ibm...@googlegroups.com, ste...@stephentanner.com
OK so after more tinkering, I have narrowed it down to working with the db2cli tool to confirm the config file is correct. Additionally it works with Python 3 on my system just fine however Python 2.7 is not working.

I will try using strace to see if I can figure out where it is going wrong.

On Wednesday, May 27, 2015 at 1:57:10 PM UTC-4, Rahul wrote:

Rahul

unread,
May 28, 2015, 2:29:11 AM5/28/15
to ibm...@googlegroups.com, ste...@stephentanner.com

Hi Stephen,
  Config file is not being used by ibm_db driver but it is used by DS driver package. Please check which DS driver libraries getting used by ibm_db, you can check this with ldd command on ibm_db.so file which would be in your Python-2.7's site-packages directory.

Thanks,
Rahul

Stephen Tanner

unread,
May 28, 2015, 10:54:07 AM5/28/15
to ibm...@googlegroups.com, ste...@stephentanner.com
$ ldd /usr/lib/python2.7/site-packages/ibm_db.so
    linux-vdso.so.1 (0x00007fffff13a000)
    libdb2.so.1 => /usr/lib/python2.7/site-packages/clidriver/lib/libdb2.so.1 (0x00007f2ed7f09000)
    libpython2.7.so.1.0 => /usr/lib/libpython2.7.so.1.0 (0x00007f2ed7b3c000)
    libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f2ed791f000)
    libc.so.6 => /usr/lib/libc.so.6 (0x00007f2ed757d000)
    libcrypt.so.1 => /usr/lib/libcrypt.so.1 (0x00007f2ed7345000)
    libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f2ed7141000)
    librt.so.1 => /usr/lib/librt.so.1 (0x00007f2ed6f39000)
    libpam.so.0 => /usr/lib/libpam.so.0 (0x00007f2ed6d2a000)
    libxml2.so.2 => /usr/lib/libxml2.so.2 (0x00007f2ed69c5000)
    libm.so.6 => /usr/lib/libm.so.6 (0x00007f2ed66c1000)
    libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007f2ed633f000)
    libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f2ed6129000)
    libutil.so.1 => /usr/lib/libutil.so.1 (0x00007f2ed5f26000)
    /usr/lib64/ld-linux-x86-64.so.2 (0x00007f2eda31e000)
    libz.so.1 => /usr/lib/libz.so.1 (0x00007f2ed5d10000)
    liblzma.so.5 => /usr/lib/liblzma.so.5 (0x00007f2ed5aea000)

Rahul

unread,
May 28, 2015, 11:09:43 AM5/28/15
to ibm...@googlegroups.com, ste...@stephentanner.com
Hi Stephen,
  If you wants to use your default DS Driver, then please delete "/usr/lib/python2.7/site-
packages/clidriver/" .

Thanks,
Rahul

Stephen Tanner

unread,
May 28, 2015, 11:26:40 AM5/28/15
to ibm...@googlegroups.com
I guess that would mean the setup.py script is not detecting my copy of DSdriver and still trying to use it's own copy but only does this for python 2.7?

I know the folder is removed during the uninstall of ibm_db so that directory is a byproduct of the pip install.

Additionally, DSdriver requires a config file of one fashion or another, where would they be located in the event of pip install providing a copy of the DSdriver? if they are in the site-packages folder is there a possibility that they could be overwritten on updates/future installs?

--
Stephen Tanner
Web, Research, and Cloud Application Developer
Virginia Tech Transportation Institute
https://StephenTanner.com


--
You received this message because you are subscribed to a topic in the Google Groups "ibm_db" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ibm_db/x8xHRkkW8Uk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ibm_db+un...@googlegroups.com.
To post to this group, send email to ibm...@googlegroups.com.
Visit this group at http://groups.google.com/group/ibm_db.
For more options, visit https://groups.google.com/d/optout.

Stephen Tanner

unread,
May 28, 2015, 11:44:27 AM5/28/15
to ibm...@googlegroups.com
Actually, the same issue is present in Python 3

--
Stephen Tanner
Web, Research, and Cloud Application Developer
Virginia Tech Transportation Institute
https://StephenTanner.com


Rahul

unread,
May 28, 2015, 12:04:44 PM5/28/15
to ibm...@googlegroups.com, ste...@stephentanner.com
setup.py install script detect a copy of DS Driver through IBM_DB_HOME configuration variable, It doesn't scan the disc to detect DS Driver. 

Since you are setting IBM_DB_HOME before pip install, you might is using #sudo pip install , in this way the current terminal's environment variable doesn't  apply for sudo user. You need to first use #sudo -s, then set IBM_DB_HOME and issue pip install command.


>>>
Additionally, DSdriver requires a config file of one fashion or another, where would they be located in the event of pip install providing a copy of the DSdriver? if they are in the site-packages folder is there a possibility that they could be overwritten on updates/future installs?
<<<
you can find db2dsdriver.cfg config file in your "/usr/lib/python2.7/site-packages/clidriver/cfg" directory. DS Driver will get updated during update/future instals.

Thanks,
Rahul

Stephen Tanner

unread,
May 28, 2015, 12:06:18 PM5/28/15
to ibm...@googlegroups.com
Never mind, seems to work just fine in Python 3 even though /usr/lib/python3.4/site-packages/clidriver/ exists.

This would indicate that the code use to check which copy of dsdriver/clidriver to call from ibm_db is not working on (for my system) with Python 2.7

--
Stephen Tanner
Web, Research, and Cloud Application Developer
Virginia Tech Transportation Institute
https://StephenTanner.com


Stephen Tanner

unread,
May 28, 2015, 12:19:40 PM5/28/15
to ibm...@googlegroups.com
Hmm so why would it work fine for Python 3 but not Python 2?

Additionally when I step through the setup.py installer with pdb I can see it find the environment var just fine.

Re-exporting the environment vars in a sudo -s shell did work for re-installing so that's good. This probably explains why it works when building my docker images.

So just to be clear, if a user opts to not pre-install dsdriver, you will not only install one for them but do it in a way where you will wipe any DSN's that have been setup previously by the user in a cfg file?

Is there no way to reference the cfg file in a location outside of somewhere that will be written over on updates without also manually setting up the DSDriver package?

--
Stephen Tanner
Web, Research, and Cloud Application Developer
Virginia Tech Transportation Institute
https://StephenTanner.com


--

Rahul

unread,
May 28, 2015, 1:38:54 PM5/28/15
to ibm...@googlegroups.com, ste...@stephentanner.com
You can use the DB2DSDRIVER_CFG_PATH registry variable to specify a different location for the db2dsdriver.cfg file (http://www-01.ibm.com/support/knowledgecenter/SSEPGG_10.5.0/com.ibm.swg.im.dbclient.config.doc/doc/r0061058.html?cp=SSEPGG_10.5.0%2F2-0-2-5-7-0-0)

>>>
Hmm so why would it work fine for Python 3 but not Python 2?
<<<
yes,  If you did same sudo pip install for both in same environment then behavior should be same.

>>>
Additionally when I step through the setup.py installer with pdb I can see it find the environment var just fine.
<<<
Then it should not go to code snippet which install local copy of DS Driver. Is in this case also local copy of DS Driver get installed ?
To unsubscribe from this group and all its topics, send an email to ibm_db+unsubscribe@googlegroups.com.

Mario Briggs

unread,
May 28, 2015, 1:52:41 PM5/28/15
to ibm...@googlegroups.com, ste...@stephentanner.com
>>
So just to be clear, if a user opts to not pre-install dsdriver, you will not only install one for them but do it in a way where you will wipe any DSN's that have been setup previously by the user in a cfg file?
<<
Not true about wiping away. We don't delete any earlier files that were under 'user' control. If a user uses a dsdriver.cfg in the situation where setup.py installed the CLI/DSDriver dependency, we expect the user will maintain this outside of the '/usr/lib/python2xx/site-packages' (will be too hard in the first place to keep it in this internal directory). A user can control where the dsdriver.cfg is picked by  setting the DB2DSDRIVER_CFG_PATH env var. True this has not been documented, but we will use this to document this.
 
>>
Is there no way to reference the cfg file in a location outside of somewhere that will be written over on updates without also manually setting up the DSDriver package?
<<
Using  DB2DSDRIVER_CFG_PATH env var

thanks
Mario 

Stephen Tanner

unread,
May 29, 2015, 1:28:00 AM5/29/15
to ibm...@googlegroups.com
@Mario thank you!

That is critical info to have documented. Maybe I can just stop using my install of the dsdriver and use the one shipped with setup.py and then configure DB2DSDRIVER_CFG_PATH env var to point at my dsdriver.cfg

I can however confirm that installing both Python 2/3 versions of ibm-db behaves differently post install.

using:

    sudo pip2 install ibm-db

the clidriver folder/module is indeed installed and when using python 2.7 attempting to make a connection will fail due to not picking up the system installed dsdriver unless I remove the copy of clidriver from the site-packages folder.


using Python3

    sudo pip install ibm-db


The clidriver folder/module is again installed. However when launching a Python REPL/script there is no exception throw as the correct config file is found and used.

Also I tried exporting DB2DSDRIVER_CFG_PATH after confirming Python 2 is not working with only IBM_DB_HOME env var and was pleased to find it was able to pick up the right config file so at a minimum I have a suitable work around for this bug.

Thank you both for your help so far. Is there any additional information about my system I can give you that could help?

--
Stephen Tanner
Web, Research, and Cloud Application Developer
Virginia Tech Transportation Institute
https://StephenTanner.com


Reply all
Reply to author
Forward
0 new messages