通过sqlalchemy连接prestodb
connect prestodb through sqlalchemy
我想使用 SQLalchemy 接口连接到 prestodb。我是 运行 prestodb==0.7.0
和 SQLalchemy== 1.4.20
并且 SQLalchemy 似乎没有内置 prestodb:
NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:presto
注册 prestodb
也不太幸运:
from sqlalchemy.dialects import registry
import prestodb
from prestodb.dbapi import Connection
registry.register('presto', 'prestodb.dbapi', 'Connection')
from sqlalchemy.engine import create_engine
port = 8889
user = os.environ["USER"]
engine = create_engine(f'presto://{user}@presto:{port}/hive',
connect_args={'protocol': 'https', 'requests_kwargs': {'verify': False}})
db = engine.raw_connection()
# AttributeError: type object 'Connection' has no attribute 'get_dialect_cls'
有什么想法吗?
如果你看一下 Dialects docs you will see that Presto
is a external dialect and needs to be installed separately. The Presto dialect is supported through PiHyve 并且可以使用 pip install 'pyhive[presto]'
安装。
我想使用 SQLalchemy 接口连接到 prestodb。我是 运行 prestodb==0.7.0
和 SQLalchemy== 1.4.20
并且 SQLalchemy 似乎没有内置 prestodb:
NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:presto
注册 prestodb
也不太幸运:
from sqlalchemy.dialects import registry
import prestodb
from prestodb.dbapi import Connection
registry.register('presto', 'prestodb.dbapi', 'Connection')
from sqlalchemy.engine import create_engine
port = 8889
user = os.environ["USER"]
engine = create_engine(f'presto://{user}@presto:{port}/hive',
connect_args={'protocol': 'https', 'requests_kwargs': {'verify': False}})
db = engine.raw_connection()
# AttributeError: type object 'Connection' has no attribute 'get_dialect_cls'
有什么想法吗?
如果你看一下 Dialects docs you will see that Presto
is a external dialect and needs to be installed separately. The Presto dialect is supported through PiHyve 并且可以使用 pip install 'pyhive[presto]'
安装。