What I am trying to do: I am trying to connect to an Informix DB from Linux (RHEL 8.9) using Python. The python module I am using is pyodbc. The driver is data direct informix driver - ddifcl28.so
I am able to make connection using conn = pyodbc.connect(<db_connection_details>) and create cursor using cursor = conn.cursor()
Error: But when I try to run sql using cursor cursor.execute("SELECT count(*) FROM SYSTABLES;") I get following error:
6066:
[DataDirect][ODBC 20101 driver]1508[DataDirect][ODBC 20101 driver]6060[DataDirect][ODBC 20101 driver]6062
Traceback (most recent call last):
File "test_informix.py", line 7, in <module>
cursor.execute("SELECT count(*) FROM SYSTABLES;")
pyodbc.Error: ('6000', '[6000] [DataDirect][ODBC 20101 driver][20101]10856 (-256) (SQLExecDirectW)')
What I have tried so far: I am unable to find much information about data direct driver but from this post found following:
*To resolve this issue, verify the following configuration:
- Under $ODBCHOME/locale/en_US/LC_MESSAGES, verify that the files have the read and execute permissions for the OS user.
- In the odbc.ini file, verify that InstallDir path is pointing to $ODBCHOME path.*
So I changed file permission from 644 to 755 for all the files under /app_software/datadirect_informix/ODBC_64bit/locale/en_US/LC_MESSAGES/ and ensured /app_software/datadirect_informix/ODBC_64bit/odbc.ini has following set to InstallDir.
[ODBC]
InstallDir=/app_software/datadirect_informix/ODBC_64bit
But I still get same error as above. We don't have ODBCHOME environment variable but a different one, ODBCINI is there which points to a different odbc.ini (/app_software/odbc/.odbc.ini) which is currently being used. Could this be causing the trouble?
If I just change the driver path in conn = pyodbc.connect(<db_connection_details>) to an existing ibm informix driver we have (iclit09b.so) then same code snippet works and SQL completes.
My complete code is:
import pyodbc
conn = pyodbc.connect("DRIVER={/app_software/ibm/informix/4.10/lib/cli/iclit09b.so};Host=host.name.com;PROTOCOL=onsoctcp;Server=server_name;PORT=50000;SERVICE=informix;DATABASE=db_name;UID=USER_ID;PWD=user_pwd;;DB_LOCALE=en_us.utf8;CLIENT_LOCALE=en_us.utf8")
conn.setdecoding(pyodbc.SQL_WCHAR, encoding='UTF-8')
conn.setdecoding(pyodbc.SQL_CHAR, encoding='UTF-8')
conn.setencoding(encoding='UTF-8')
cursor.execute("SELECT count(*) FROM SYSTABLES;")
print(f"AFTER cursor.execute: cursor={type(cursor)}={cursor}")
for row in cursor:
print('row = %r' %(row,))
Question: What am I missing here? We want to switch from existing ibm informix driver (iclit09b.so) to data direct informix driver - ddifcl28.so so trying to see how to set it up properly.