Hello, Python Community!
Has someone been able to successfully connect to an IBM Informix DB with a Python app? I have the following environment: DEV: Windows 11 Python 3.13.3 64-bit VS Code
DB: IBM Informix 12.10 hosted in Azure I'm able to connect to it usind DBeaver (JDBC)
I have tried the following libraries to try to establish the connection:
ibm_db:
Traceback (most recent call last): File "c:\Users\peterg\source\python\dbApp\ibm_db_test.py", line 1, in <module> import ibm_db as db ImportError: DLL load failed while importing ibm_db: The specified module could not be found._
pyodbc:
I have an ODBC DSN connection established
Traceback (most recent call last): File "c:\Users\peterg\source\python\dbApp\pyodbc_test.py", line 3, in <module> conn = db.connect("Dsn='DSN_NAME'") pyodbc.InterfaceError: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')
JayDeBeAPI: I have downloaded the same JAR files as DBeaver uses and copied them to a dir local to the project and added the CLASSPATH variable: set "CLASSPATH=%PROJECT_ROOT%\Java\jbc-4.50.10.1.jar:%PROJECT_ROOT%\Java\bson-3.8.0.jar"
File "c:\Users\peterg\source\python\dbApp\JayDeBeApi_test.py", line 3, in <module> dbConn = db.connect("com.informix.jdbc.IfxDriver", "jdbc:informix-sqli://hostname:port/db_name:INFORMIXSERVER=server_name", ['user', 'pass']) File "C:\Users\peterg\AppData\Local\Programs\Python\Python313\Lib\site-packages\jaydebeapi\__init__.py", line 412, in connect jconn = _jdbc_connect(jclassname, url, driver_args, jars, libs) File "C:\Users\peterg\AppData\Local\Programs\Python\Python313\Lib\site-packages\jaydebeapi\__init__.py", line 221, in _jdbc_connect_jpype jpype.JClass(jclassname) ~~~~~~~~~~~~^^^^^^^^^^^^ File "C:\Users\peterg\AppData\Local\Programs\Python\Python313\Lib\site-packages\jpype\_jclass.py", line 99, in __new__ return _jpype._getClass(jc) ~~~~~~~~~~~~~~~~^^^^ TypeError: Class com.informix.jdbc.IfxDriver is not found
PyInformix:
SADeprecationWarning: The dbapi() classmethod on dialect classes has been renamed to import_dbapi(). Implement an import_dbapi() classmethod directly on class <class 'pyinformix.ifx_jdbc.InformixJDBCDialect'> to remove this warning; the old .dbapi() classmethod may be maintained for backwards compatibility. engine = create_engine('informix+ifx_jdbc://hostname:port/db_name;INFORMIXSERVER=server_name;delimident=y;user=user;password=pass') Traceback (most recent call last): File "c:\Users\peterg\source\python\dbApp\PyInformix_test.py", line 5, in <module> conn = engine.connect() File "C:\Users\peterg\AppData\Local\Programs\Python\Python313\Lib\site-packages\sqlalchemy\engine\base.py", line 3274, in connect return self._connection_cls(self) ~~~~~~~~~~~~~~~~~~~~^^^^^^ File "C:\Users\peterg\AppData\Local\Programs\Python\Python313\Lib\site-packages\sqlalchemy\engine\base.py", line 146, in __init__ self._dbapi_connection = engine.raw_connection() ~~~~~~~~~~~~~~~~~~~~~^^ File "C:\Users\peterg\AppData\Local\Programs\Python\Python313\Lib\site-packages\sqlalchemy\engine\base.py", line 3298, in raw_connection return self.pool.connect() ~~~~~~~~~~~~~~~~~^^ File "C:\Users\peterg\AppData\Local\Programs\Python\Python313\Lib\site-packages\sqlalchemy\pool\base.py", line 449, in connect return _ConnectionFairy._checkout(self) ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^ File "C:\Users\peterg\AppData\Local\Programs\Python\Python313\Lib\site-packages\sqlalchemy\pool\base.py", line 1264, in _checkout fairy = _ConnectionRecord.checkout(pool) File "C:\Users\peterg\AppData\Local\Programs\Python\Python313\Lib\site-packages\sqlalchemy\pool\base.py", line 713, in checkout rec = pool._do_get() File "C:\Users\peterg\AppData\Local\Programs\Python\Python313\Lib\site-packages\sqlalchemy\pool\impl.py", line 179, in _do_get with util.safe_reraise(): ~~~~~~~~~~~~~~~~~^^ File "C:\Users\peterg\AppData\Local\Programs\Python\Python313\Lib\site-packages\sqlalchemy\util\langhelpers.py", line 146, in __exit__ raise exc_value.with_traceback(exc_tb) File "C:\Users\peterg\AppData\Local\Programs\Python\Python313\Lib\site-packages\sqlalchemy\pool\impl.py", line 177, in _do_get return self._create_connection() ~~~~~~~~~~~~~~~~~~~~~~~^^ File "C:\Users\peterg\AppData\Local\Programs\Python\Python313\Lib\site-packages\sqlalchemy\pool\base.py", line 390, in _create_connection return _ConnectionRecord(self) File "C:\Users\peterg\AppData\Local\Programs\Python\Python313\Lib\site-packages\sqlalchemy\pool\base.py", line 675, in __init__ self.__connect() ~~~~~~~~~~~~~~^^ File "C:\Users\peterg\AppData\Local\Programs\Python\Python313\Lib\site-packages\sqlalchemy\pool\base.py", line 901, in __connect with util.safe_reraise(): ~~~~~~~~~~~~~~~~~^^ File "C:\Users\peterg\AppData\Local\Programs\Python\Python313\Lib\site-packages\sqlalchemy\util\langhelpers.py", line 146, in __exit__ raise exc_value.with_traceback(exc_tb) File "C:\Users\peterg\AppData\Local\Programs\Python\Python313\Lib\site-packages\sqlalchemy\pool\base.py", line 897, in __connect self.dbapi_connection = connection = pool._invoke_creator(self) ~~~~~~~~~~~~~~~~~~~~^^^^^^ File "C:\Users\peterg\AppData\Local\Programs\Python\Python313\Lib\site-packages\sqlalchemy\engine\create.py", line 646, in connect return dialect.connect(*cargs, **cparams) ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^ File "C:\Users\peterg\AppData\Local\Programs\Python\Python313\Lib\site-packages\sqlalchemy\engine\default.py", line 625, in connect return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^ File "C:\Users\peterg\AppData\Local\Programs\Python\Python313\Lib\site-packages\jaydebeapi\__init__.py", line 412, in connect jconn = _jdbc_connect(jclassname, url, driver_args, jars, libs) File "C:\Users\peterg\AppData\Local\Programs\Python\Python313\Lib\site-packages\jaydebeapi\__init__.py", line 221, in _jdbc_connect_jpype jpype.JClass(jclassname) ~~~~~~~~~~~~^^^^^^^^^^^^ File "C:\Users\peterg\AppData\Local\Programs\Python\Python313\Lib\site-packages\jpype\_jclass.py", line 99, in __new__ return _jpype._getClass(jc) ~~~~~~~~~~~~~~~~^^^^ TypeError: Class com.informix.jdbc.IfxDriver is not found
IfxPy:
Uanble to install, seems that it does not support the latest Python 3 version.
Any help would be appreciated. I can attach the sample code of every method I tried if that would help.
becomes
If this is a sqlalchemy engine connect url then it would look like the fixed one.
It seems that the JBDC driver has a requirement for having 2 JAR files (JDBC driver and BLOB object) which I have but can't figure out how to specify the path.
No normal sqa user will have any clue how to do this.
might wanna take this up with the sqlachemy maintainers OR look at sqlachemy tests for how they are testing driver integration.
Some other dialect+driver will do the exact same thing as this jbdc driver.