Cannot connect to Informix database via Python
Posted in 2025
Malcom Terry got SQL30081N connecting to Informix from Python with ibm_db. Andreas Legner explained this is a DRDA error and needs a drsoctcp listener; Benjamin Thompson recommended the IfxPy driver instead. IfxPy failed to install or compile for Malcom on modern Python (use_2to3, gcc errors) despite a recent HCL fix; Javier Sagrera built it on CentOS 9. Unresolved.
Auto-generated by Claude from the posts below — may be imperfect; read the full thread.
Topics: Error Codes & Troubleshooting, Networking & sqlhosts Configuration
I am trying to modify an existing Python script that has run in a customer environment, but fails to connect in any of my local environments: Windows, Ubuntu or CentOS. They all return essentially the same error using packages SQLAlchemy, ibm_db of IfxPy: Exception: [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: "xxx". Communication function detecting the error: "recv". Protocol specific error code(s): "*", "*", "0". SQLSTATE=08001 SQLCODE=-30081 I have simplified the script: import ibm_db conn_str = "DATABASE=mydb;HOSTNAME=myhost;PORT=portnum;PROTOCOL=TCPIP;UID=myuser;PWD=mypw;SERVER=mydbs" conn = ibm_db.connect(conn_str, "", "") Does anyone have any idea what may be the cause for the error? ------------------------------ Malcom Terry ------------------------------
what is in your sqlhosts file ? On 5/5/2025 7:37 AM, Malcom Terry via IBM TechXchange Community wrote: 01000196a0e1356a-c9bb359d-2d22-42dc-b2c3-e548d7b5fa47-000000@email.amazonses.com"> I am trying to modify an existing Python script that has run in a customer environment, but fails to connect in any of my local environments:... -posted to the "Informix" group
I am not sure, but you may want to try changing the protocol to drsoctcp or onsoctcp. ------------------------------ Mike Walker xDB Systems, Inc www.xdbsystems.com ------------------------------
onlinedsa onipcshm frkpvreact01 def
onlinedsasoc onsoctcp frkpvreact01 infmx_frkpvreact01
------------------------------Malcom Terry
------------------------------
Yep, 30081 I know as DRDA connection error (https://www.ibm.com/docs/en/db2/11.5.x?topic=errors-sql30081n-tcpip-communication), which is quite expected if there's no DRDA port/listener configured. -> you'll need another listener (DBSERVERALIASES entry) in your onconfig and a related line in sqlhosts using drsoctcp protocol. All this assuming you're bound to using the Db2 DRDA driver rather than an Informix SQLI driver to connect your application to Informix. Others will be able to point you to the native Informix Python driver. Andreas ------------------------------ Andreas Legner Informix Dev HCL Software ------------------------------
Malcolm, I would recommend using IfxPy and not the ibm_db driver which is really for DB2. This was just a stop-gap solution that works because Informix can accept connections from DB2 client tools on drsoctcp listeners but as it is not actually DB2, you may find some complications or missing features when you get into the actual coding. Dependent on what you are doing of course. If you install and use the IfxPy driver you will be able to connect through either TCP to your listener onlinedsasoc or shared memory to onlinedsa if running locally on the machine. Here is code I use to connect which uses sqlhosts import IfxPy import sys ConStr = "SERVER=onlinedsasoc;DATABASE=sysmaster;HOST= frkpvreact01;SERVICE=infmx_frkpvreact01" try: conn = IfxPy.connect( ConStr, "", "") except Exception as e: print ('ERROR: Connect to sysmaster database failed') print ( e ) sys.exit(1) You may need to add the user and password details to your connection string. I hope this helps, Ben. ------------------------------ Benjamin Thompson ------------------------------
Thanks Benjamin, I tried "pip install IfxPy" on Windows 11 and on Ubuntu 22.04. Both return error: error in IfxPy setup command: use_2to3 is invalid It seems that latest releases of setuptools have removed that package. Also, IfxPy hasn't been maintained since 2020. --Malcom Terry ------------------------------ Malcom Terry ------------------------------
Hi Malcom, I followed following document and it worked for me using sqlhosts onsoctcp protocol. https://github.com/OpenInformix/IfxPy Note: Client SDK should be installed and LD_LIBRARY_PATH should be exported. Regards, Nandkishor ------------------------------ Nandkishor Singare ------------------------------
Malcolm,
I thought we might get to the problem being the installation. I use Rocky or RHEL 8 which ships with the slightly ancient Python 3.6 which may be why it works for me.
With Client SDK installed, my installation steps are:
dnf install rpm-build gcc python3 python3-pip python3-libs python3-devel
-y
export CSDK_HOME=/path/to/csdk
export INFORMIXDIR=/path/to/csdkpip3 install ifxpy
Have you seen
https://stackoverflow.com/questions/72414481/error-in-anyjson-setup-command-use-2to3-is-invalid
as the error you have posted looks to be a common issue and has a workaround you can try related to setuptools?
Otherwise the drsoctcp listener and ibm_db driver might be your only option. I will ask HCL about the IfxPy driver next time I am on a call with them.
Ben.
------------------------------
Benjamin Thompson
------------------------------
Ben, I've tried many of the suggested things in the link about use_2to3 error and nothing has worked. I even tried to install without pip, python setup.py install , and gcc failed to compile. I think IfxPy is just too old and not compatible with modern Linux releases. I have also tried Python packages SQLAlchemy and ibm_db . They both refuse to connect eith error: Exception: [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: "x.x.x.x". Communication function detecting the error: "recv". Protocol specific error code(s): "*", "*", "0". SQLSTATE=08001 SQLCODE=-30081 The only client I have been able to connect with is DBeaver 25.0.5 : So we know we can connect to the database, just not with any Python drivers. I tried all this on CentOS 10 and Ubuntu 22.04. Thanks, Malcom ------------------------------ Malcom Terry ------------------------------
I believe HCL has done a fix in the last week or so to the IfxPy code. Have you seen this and tried it? Ben. ------------------------------ Benjamin Thompson ------------------------------
Where may I find it? It's not on pypi.org. ------------------------------ Malcom Terry ------------------------------
https://github.com/OpenInformix/IfxPy ------------------------------ Benjamin Thompson ------------------------------
Ben, I found it and see that some changes have be made last week and back in December. Here is what I tried: Installed the latest Python version 3.13.3 Tried to install the IfxPy package via python setup.py install . It failed to compile. I saw in the terminal output: Please avoid running ``setup.py`` directly. Instead, use pypa/build, pypa/installer or other standards-based tools. I then installed the build package via pip install build Next I executed python -m build and it also failed to compile. See attached terminal outputs. Thanks ------------------------------ Malcom Terry ------------------------------
Hi Malcolm, I was on annual leave last week, hence no reply. Unless HCL can understand and correct the error 'gcc' throws I can only look to reproduce your issue. To help me, I have an RPM spec file I use in Docker builder which works by running 'pip3 install ifxpy' then packaging all the files that result. It can be adapted to different Linux flavours, provided your distro uses RPM. Regardless it provides a scripted set up that works every time (for Rocky 8 and Python 3.6). Did you try 'pip3 install ifxpy' since HCL did the fix here? https://github.com/OpenInformix/IfxPy/commit/57b8a602e80fbd17a5e14485fc5fe2de64d5fec2 What is your build environment - Linux flavour, version, steps taken to install newer Python release? Ben. ------------------------------ Benjamin Thompson ------------------------------
Ben, I've tried various ways to build a new package using the updated Git repo, but no success. I'm currently using a CentOS 10 VM and a CentOS 7.9 VM with virtual (pyenv) Python 3.8. Thanks, Malcom ------------------------------ Malcom Terry ------------------------------
Hi Malcon,
Would you mind to share the error you are getting in your system?
I just tried on a fresh VM running CentOS 9 (GCC 11.5 and
Python 3.9.21) and it builds fine directly from source.
There was a warning regarding SQLLEN vs SQLINTEGER for SQLRowCount() which need some fixing. Maybe on your platform the compiler is taking that as an error.
Regards,
Javier
Thanks,
Javier
------------------------------
Javier Sagrera
------------------------------
Ben,
I've tried various ways to build a new package using the updated Git repo, but no success.
I'm currently using a CentOS 10 VM and a CentOS 7.9 VM with virtual (pyenv) Python 3.8.
Thanks,
Malcom
------------------------------
Malcom Terry
------------------------------
Original Message:
Sent: Mon June 02, 2025 06:28 AM
From: Benjamin Thompson
Subject: Cannot connect to Informix database via Python
Hi Malcolm,
I was on annual leave last week, hence no reply.
Unless HCL can understand and correct the error 'gcc' throws I can only look to reproduce your issue. To help me, I have an RPM spec file I use in Docker builder which works by running 'pip3 install ifxpy' then packaging all the files that result. It can be adapted to different Linux flavours, provided your distro uses RPM. Regardless it provides a scripted set up that works every time (for Rocky 8 and Python 3.6).
Did you try 'pip3 install ifxpy' since HCL did the fix here?
https://github.com/OpenInformix/IfxPy/commit/57b8a602e80fbd17a5e14485fc5fe2de64d5fec2
What is your build environment - Linux flavour, version, steps taken to install newer Python release?
Ben.
------------------------------
Benjamin Thompson
Original Message:
Sent: Thu May 22, 2025 01:20 PM
From: Malcom Terry
Subject: Cannot connect to Informix database via Python
Ben,
I found it and see that some changes have be made last week and back in December. Here is what I tried:
Installed the latest Python version 3.13.3
Tried to install the IfxPy package via python
setup.py install
. It failed to compile.
I saw in the terminal output:
Please avoid running ``setup.py`` directly.
Instead, use pypa/build, pypa/installer or other
standards-based tools.
I then installed the build package via
pip install build
Next I executed
python -m build
and it also failed to compile.
See attached terminal outputs.
Thanks
------------------------------
Malcom Terry
Original Message:
Sent: Thu May 22, 2025 11:50 AM
From: Benjamin Thompson
Subject: Cannot connect to Informix database via Python
https://github.com/OpenInformix/IfxPy
------------------------------
Benjamin Thompson
Original Message:
Sent: Thu May 22, 2025 11:33 AM
From: Malcom Terry
Subject: Cannot connect to Informix database via Python
Where may I find it? It's not on pypi.org.
------------------------------
Malcom Terry
Original Message:
Sent: Thu May 22, 2025 03:57 AM
From: Benjamin Thompson
Subject: Cannot connect to Informix database via Python
I believe HCL has done a fix in the last week or so to the IfxPy code. Have you seen this and tried it?
Ben.
------------------------------
Benjamin Thompson
Original Message:
Sent: Wed May 21, 2025 08:15 PM
From: Malcom Terry
Subject: Cannot connect to Informix database via Python
Ben,
I've tried many of the suggested things in the link about
use_2to3
error and nothing has worked. I even tried to install without pip,
python setup.py install
, and gcc failed to compile. I think
IfxPy
is just too old and not compatible with modern Linux releases.
I have also tried Python packages
SQLAlchemy
and
ibm_db
. They both refuse to connect eith error:
Exception: [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: "x.x.x.x". Communication function detecting the error: "recv". Protocol specific error code(s): "*", "*", "0". SQLSTATE=08001 SQLCODE=-30081
The only client I have been able to connect with is
DBeaver 25.0.5
:
So we know we can connect to the database, just not with any Python drivers.
I tried all this on CentOS 10 and Ubuntu 22.04.
Thanks,
Malcom
------------------------------
Malcom Terry
Original Message:
Sent: Fri May 09, 2025 04:24 AM
From: Benjamin Thompson
Subject: Cannot connect to Informix database via Python
Malcolm,
I thought we might get to the problem being the installation. I use Rocky or RHEL 8 which ships with the slightly ancient Python 3.6 which may be why it works for me.
With Client SDK installed, my installation steps are:
dnf install rpm-build gcc python3 python3-pip python3-libs python3-devel
-y
export CSDK_HOME=/path/to/csdk
export INFORMIXDIR=/path/to/csdkpip3 install ifxpy
Have you seen
https://stackoverflow.com/questions/72414481/error-in-anyjson-setup-command-use-2to3-is-invalid
as the error you have posted looks to be a common issue and has a workaround you can try related to setuptools?
Otherwise the drsoctcp listener and ibm_db driver might be your only option. I will ask HCL about the IfxPy driver next time I am on a call with them.
Ben.
------------------------------
Benjamin Thompson
Original Message:
Sent: Thu May 08, 2025 02:21 PM
From: Malcom Terry
Subject: Cannot connect to Informix database via Python
Thanks Benjamin,
I tried "pip install IfxPy" on Windows 11 and on Ubuntu 22.04. Both return error:
error in IfxPy setup command: use_2to3 is invalid
It seems that latest releases of setuptools have removed that package. Also, IfxPy hasn't been maintained since 2020.
--Malcom Terry
------------------------------
Malcom Terry
Original Message:
Sent: Thu May 08, 2025 04:49 AM
From: Benjamin Thompson
Subject: Cannot connect to Informix database via Python
Malcolm,
I would recommend using IfxPy and not the ibm_db driver which is really for DB2. This was just a stop-gap solution that works because Informix can accept connections from DB2 client tools on drsoctcp listeners but as it is not actually DB2, you may find some complications or missing features when you get into the actual coding. Dependent on what you are doing of course.
If you install and use the IfxPy driver you will be able to connect through either TCP to your listener
onlinedsasoc
or shared memory to
onlinedsa
if running locally on the machine.
Here is code I use to connect which uses sqlhosts
import IfxPy
import sys
ConStr = "SERVER=onlinedsasoc;DATABASE=sysmaster;HOST=
frkpvreact01;SERVICE=infmx_frkpvreact01"
try:
conn = IfxPy.connect( ConStr, "", "")
except Exception as e:
print ('ERROR: Connect to sysmaster database failed')
print ( e )
sys.exit(1)
You may need to add the user and password details to your connection string.
I hope this helps,
Ben.
------------------------------
Benjamin Thompson