Incompatibility with SQLAlchemy 2.0.0+
SQLAlchemy 2.0.0 has been released on the 26th of January 2023, and it's incompatible with PyHive for connections to Presto, Trino and Hive:
from sqlalchemy import create_engine
create_engine('presto://foo:bar@host')
# results in
File "/some/path/pyhive/sqlalchemy_presto.py", line 16, in <module>
from sqlalchemy.databases import mysql
ModuleNotFoundError: No module named 'sqlalchemy.databases'
Similarly,
from sqlalchemy import create_engine
create_engine('trino://foo:bar@host')
# results in
File "/some/path/sqlalchemy/util/langhelpers.py", line 366, in load
"Can't load plugin: %s:%s" % (self.group, name)
sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:trino
and
from sqlalchemy import create_engine
create_engine('hive://foo:bar@host')
# results in
File "/some/path/pyhive/sqlalchemy_hive.py", line 16, in <module>
from sqlalchemy import processors
ImportError: cannot import name 'processors' from 'sqlalchemy' (/some/path/sqlalchemy/__init__.py)
Pinning SQLAlchemy<2.0.0 resolves the issue.
I've added a pull request to fix this:
https://github.com/dropbox/PyHive/pull/447
I'm not able to sign the CLA at the moment, so the pull won't get approved - but the changes are almost trivial - if you inspect the request you can see how it's done.
I've added a pull request to fix this:
#447
I'm not able to sign the CLA at the moment, so the pull won't get approved - but the changes are almost trivial - if you inspect the request you can see how it's done.
Nice work! Although I suspect for complete compatibility there needs to be a fix in pyhive/sqlalchemy_trino.py and pyhive/sqlalchemy_presto.py as well.
Could it be merged please ?
This PR https://github.com/dropbox/PyHive/pull/448 includes the change and has been merged. But then got reverted here: https://github.com/dropbox/PyHive/commit/df03bef66500541fa921ec3614ec06a15ca17615
@bkyryliuk what's the situation atm?
I am working on a comprehensive PR to add SQLAlchemy 2.0 Support. Should be ready soon.
PR raised https://github.com/dropbox/PyHive/pull/457
PR https://github.com/dropbox/PyHive/pull/457 is merged.
@PApostol @james1465 @belgacea @glungley
PyHive is now compatible with SQLAlchemy 2.0. See https://github.com/dropbox/PyHive/pull/457 This is released in 0.7.1.dev0. You are requested to test with the dev version and report any bugs in the PyHive GitHub repository before 0.7.1 is released in a month or so.
I have tried PyHive 0.7.1.dev0 with SQLAlchemy 2.0.19, it appears to work fine!
PyHive 0.7.0 is released which includes Python 3.11 and SQLAlchemy 2.0 support.