ibmdb / python-ibmdb

Automatically exported from code.google.com/p/ibm-db
Apache License 2.0
305 stars 191 forks source link

SystemError: <built-in function connect> returned NULL without setting an error #556

Closed infoakash closed 3 years ago

infoakash commented 4 years ago

I'm trying to connect to db2 with ibmdb library. Using python 3.7.6 and ibm_db==3.0.1

import ibm_db conn_str = 'database=;hostname=.cua.com.au;port=;protocol=tcpip;uid=;pwd='

removed the details from conn_str

db2Conn = ibm_db.connect(conn_str, '', '')

while executing the connect this runs into a error : SystemError: returned NULL without setting an error

imavo commented 4 years ago

Please use the version 3.0.2 of the ibm_db , and retry. You also need to tell us which Db2-server platform you try to reach (is it Db2 on Z/OS, Db2 for i-series, or Db2 for Linux/Unix/Windows) as different software driver for Db2 might be necessary if accessing Db2-for-i-series. You should also describe your workstation environment, is it MS-Windows or Linux etc, and how it is configured for python (virtual env etc?), and whether you have verified that this workstation can connect to the same database with the same credentials outside of python (for example, at the shell command line etc).

infoakash commented 4 years ago

It's DB2 Z/OS I'm trying to connect to. Using Windows 10.

Upgraded to ibm_db 3.0.2 as well. Still getting the same error.

infoakash commented 4 years ago

@SabaKauser is this something you can help with?

I read a couple of forums on this issue no plausible resolution is posted anywhere.

amukherjee28 commented 4 years ago

HI @infoakash

Can you please provide a bit more details and I can have a look into the issue.

  1. The complete error you are getting while trying the connection.
  2. Are you using the default clidriver or are you using any specific driver. Can you please provide the details for the same as well.

Please provide me the details and I will try to reproduce the same and same check.

infoakash commented 4 years ago

Hi @amukherjee28 ,

1.Script: import ibm_db conn_str = 'database=;hostname=;port=;protocol=tcpip;uid=;pwd=' #removed properties conn = ibm_db.connect(conn_str)

conn = ibm_db.connect(conn_str,'','') All what I am getting in the console is : Traceback (most recent call last): File "", line 1, in SystemError: [built-in function connect] returned NULL without setting an error

Not getting anything written back by ibm_db. conn_errormsg() as well.

  1. I am using the IBM Data Server Driver for ODBC and CLI (Windows AMD64 and Intel EM64T) Version 11.5.4 available at https://epwt-www.mybluemix.net/software/support/trial/cst/programwebsite.wss?siteId=849&h=null&p=null

And I have got the DB2 connect license file placed in the license folder inside clidriver.

imavo commented 4 years ago

Have you verified that in a cmd.exe window on Win10, that you are able to use the db2cli.exe (which is part of the clidriver) to connect to the Db2-for-Z/OS database successfully at the command line?
The idea is to prove that the clidriver can connect with the same credentials to the same database , regardless of python. This is often the way to find underlying errors and omissions in the configuration.

Once you get a successful connection using db2cli.exe validate -dsn YOURDSN -connect -user XXX -password YYY, it means that your Win10 configuration for clidriver is all good, and your python ibm_db will then connect.

To help with this, You can configure the plain xml text file called db2dsdriver.cfg file (in the clidriver\cfg directory , whose path is shown via pip show ibm_db ) with all the details of your Db2-for-Z/OS data-source (as instructed via the links on the Db2-documentation page here:

https://www.ibm.com/support/knowledgecenter/SSEPGG_11.5.0/com.ibm.swg.im.dbclient.config.doc/doc/c0054555.html

If that is too difficult for you , you can also run a CLI trace, with the db2trc command (detailed in the Db2 Knowledge centre) with these command lines:

cd clidriver install path, found with pip show ibm_db in Location: field of its output. cd clidriver\bin db2trc on -f trc.dmp --> now run your application db2trc off db2trc flw trc.dmp trc.flw db2trc fmt trc.dmp trc.fmt db2trc fmt -c trc.dmp trc.fmtc db2trc fmt -cli trc.dmp trc.cli and share these files trc.flw, trc.fmt, trc.fmtc and trc.cli files

imavo commented 4 years ago

I see that other users reported this symptom in environments where they do NOT have local-administrator privilege, and others in corporate environment where the Windows workstation has specific ACLs that restrict the behaviour in some way.

So three additional suggestions:

  1. You might want to try if different workstations / different users are impacted .
  2. You might want to see if the behaviour changes if you run your python script in a cmd window that has elevated privileged (running as local admin, for example).
  3. You also might want to run the python debugger on your script python -m pdb YOUR_SCRIPT.py and report its output.
AWADHAMBIKA commented 3 years ago

Hi Akash(@infoakash ), Does this resolve your issue? If yes, kindly close the issue else let us know if you need further help from us.

amukherjee28 commented 3 years ago

closing on this issue.

alessandroToninelli commented 1 year ago

this issue still alive. im tryin to connect but had the same error

dsn = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=IASP01;HOSTNAME=192.168.0.1;PORT=50000;PROTOCOL=TCPIP;UID=USER;PWD=PASSWORD;"
ibm_db.connect(dsn, "", "")

and this command db2cli.exe validate -dsn YOURDSN worked for me

Earammak commented 1 year ago

@alessandroToninelli Can you please share the details that are mentioned from the issue template. You can also refer the similar issues: #783, #714, #692

Thanks