ActianCorp / sqlalchemy-ingres

Python SQLAlchemy dialect for Actian databases; Actian Data Platform (nee Avalanche), Actian X, Ingres, and Vector SQL - II-5734
https://pypi.org/project/sqlalchemy-ingres/
Apache License 2.0
4 stars 4 forks source link

ModuleNotFoundError: No module named 'sqlalchemy.sql._typing' #68

Open hab6 opened 4 weeks ago

hab6 commented 4 weeks ago

PR #42 introduced a bug in the SQLAlchemy Ingres connector. The bug exists in connector versions 0.0.7 and 0.0.8.

This line was added in that PR:

from sqlalchemy.sql._typing import is_sql_compiler

Package sqlalchemy.sql._typing exists in SQLAlchemy v2 but not in SQLAlchemy v1, so trying to use the SQLAlchemy Ingres connector (post #42) with SQLAlchemy v1 (current versions) will fail with this error:

ModuleNotFoundError: No module named 'sqlalchemy.sql._typing'

Reproduction

C\test> type simple0.py
from sqlalchemy import create_engine
engine = create_engine("ingres:///iidbdb")

Fails with SQLAlchemy v1.4.54

C\test> python -m pip list
Package           Version
----------------- -------
greenlet          3.1.1
pip               24.2
pypyodbc          1.3.6
setuptools        63.2.0
SQLAlchemy        1.4.54
sqlalchemy-ingres 0.0.8
typing_extensions 4.12.2

C:\test> python simple0.py
Traceback (most recent call last):
  File "C:\test\simple0.py", line 6, in <module>
    engine = create_engine("ingres:///iidbdb")
  File "<string>", line 2, in create_engine
  File "C:\test\.venv\lib\site-packages\sqlalchemy\util\deprecations.py", line 375, in warned
    return fn(*args, **kwargs)
  File "C:\test\.venv\lib\site-packages\sqlalchemy\engine\create.py", line 518, in create_engine
    entrypoint = u._get_entrypoint()
  File "C:\test\.venv\lib\site-packages\sqlalchemy\engine\url.py", line 662, in _get_entrypoint
    cls = registry.load(name)
  File "C:\test\.venv\lib\site-packages\sqlalchemy\util\langhelpers.py", line 341, in load
    return impl.load()
  File "C:\Users\xyz\AppData\Local\Programs\Python\Python310\lib\importlib\metadata\__init__.py", line 171, in load
    module = import_module(match.group('module'))
  File "C:\Users\xyz\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\test\.venv\lib\site-packages\sqlalchemy_ingres\__init__.py", line 7, in <module>
    from sqlalchemy_ingres import base, ingresdbi, pyodbc  # , zxjdbc  # does not appear to be in SQLAlchemy 1.4.0b1
  File "C:\test\.venv\lib\site-packages\sqlalchemy_ingres\base.py", line 36, in <module>
    from sqlalchemy.sql._typing import is_sql_compiler
ModuleNotFoundError: No module named 'sqlalchemy.sql._typing'

Succeeds with SQLAlchemy v2.0.36

python -m pip list
Package           Version
----------------- -------
greenlet          3.1.1
pip               24.2
pypyodbc          1.3.6
setuptools        63.2.0
SQLAlchemy        2.0.36
sqlalchemy-ingres 0.0.8
typing_extensions 4.12.2

C:\test> python simple0.py
[('testv1                          ',), ('imadb                           ',), ('db14992                         ',), ('db15037                         ',), ('testdb
                  ',), ('demodb                          ',), ('ij25                            ',), ('sqatestdb                       ',), ('iidbdb
 ',)]

Thanks to @priyank-stack for discovering this bug.

clach04 commented 3 weeks ago

From discussion with @hab6 :

  1. @priyank-stack workaround his immediate issue by using an older version of sqlalchemy-ingres with Apache SuperSet
  2. We do not yet know know Apache SuperSet can be used with sqlalchemy version 2 (which would make this a moot issue) a. TODO take this up with Apache SuperSet upstream project, find/create an issue
  3. We suspect we could still support sqlalchemy version 1 with sqlalchemy-ingres - needs time/research
clach04 commented 3 weeks ago

From quick skim of https://github.com/apache/superset/issues?q=is%3Aissue+is%3Aopen+sqlalchemy can not see an existing ticket for v2 support.

priyank-stack commented 3 weeks ago

From quick skim of https://github.com/apache/superset/issues?q=is%3Aissue+is%3Aopen+sqlalchemy can not see an existing ticket for v2 support.

Issue open on Apache-Superset: https://github.com/apache/superset/issues/30734

hab6 commented 1 week ago

Internal tracking II-16194