Missing zxJDBC connector in sqlalchemy (With DB2)

Viewed 385

Facing issue with a sqlalchemy + db2(remote server) application.

Dependency installed:

  • SQLAlchemy==1.4.21
  • ibm-db==3.0.4
  • ibm-db-sa==0.3.6
  • python version = 3.8

Here is the connection snippet:

self.__engine = create_engine(f'ibm_db_sa://{DB2_USER}:{DB2_PASSWD}@{DB2_INSTANCE}/{DB2_DB}')

Seeing below issue:

File "/db-query-service/query_executor/db_reader/db2_reader_with_query.py", line 19, in __init__
    self.__engine = create_engine(f'ibm_db_sa://{DB2_USER}:{DB2_PASSWD}@{DB2_INSTANCE}/{DB2_DB}')
  File "<string>", line 2, in create_engine
  File "/usr/local/lib/python3.8/site-packages/sqlalchemy/util/deprecations.py", line 298, in warned
    return fn(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/create.py", line 522, in create_engine
    entrypoint = u._get_entrypoint()
  File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/url.py", line 653, in _get_entrypoint
    cls = registry.load(name)
  File "/usr/local/lib/python3.8/site-packages/sqlalchemy/util/langhelpers.py", line 337, in load
    return impl.load()
  File "/usr/local/lib/python3.8/importlib/metadata.py", line 77, in load
    module = import_module(match.group('module'))
  File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/local/lib/python3.8/site-packages/ibm_db_sa/__init__.py", line 22, in <module>
    from . import ibm_db, pyodbc, base, zxjdbc
  File "/usr/local/lib/python3.8/site-packages/ibm_db_sa/zxjdbc.py", line 32, in <module>
    from sqlalchemy.connectors.zxJDBC import ZxJDBCConnector
ModuleNotFoundError: No module named 'sqlalchemy.connectors.zxJDBC'

Questions:

  • Is there any dependency missing or mismatch in versions?
  • Is there any issue with sqlalchemy installation? - I removed and reinstalled it to rule that out.
  • Able to work with Mysql remote db.
  • zxjdbc is specific to jython i found, will db2+ Sqlalchemy work with jython implementations.?
  • If db2+ Sqlalchemy work with cpython, what's the fix for the issue?

Reference Doc:

1 Answers

Temporarily, you need to uninstall the sqlalchemy 1.4.x and as a workaround, then install the current sqlalchemy 1.3.x release . At today's date this is sqlalchemy 1.3.24 which should resolve the issue.

I expect this problem will eventually get resolved.

Link to issue is here

Related