dremio sqlalchemy 连接说明

实际上有社区已经有一个python包了,但是里边一些实现目前有一些问题(pip 包的,当然还有一些数据类型支持的问题)
我fork 进行了一些调整

一些问题

  • pandas 依赖
    应该是pyarrow的调整,我在代码setup.py 添加了
  • supports_statement_cache 问题
    我按照日志信息默认设置为了True
  • dbapi 类方法问题
    按照提示调整了
@classmethod
def import_dbapi(cls):
    import sqlalchemy_dremio.db as module
    return module
  • KeyError: 'datetime64[ms]'
    属于数据时间精度问题,此问题我也已经fix 了,在query 中添加了映射
'datetime64[ms]': types.DATETIME,
  • pip 包driver 问题
    这个实际上master 代码已经修改了,别使用pip 包就没事,推荐基于git repo 模式安装

参考代码

  • requirements.txt
    使用了github repo 进行安装
sqlalchemy-dremio@https://github.com/rongfengliang/sqlalchemy_dremio/archive/refs/heads/master.zip
  • 代码集成
from sqlalchemy import create_engine
from sqlalchemy import text
engine = create_engine("dremio+flight://admin:admin123@localhost:32010/dremio?UseEncryption=false", echo=False)
with engine.connect() as conn:
    result = conn.execute(text("select * from nessie.mydemo"))
    print(result.all())
  • 效果

说明

目前推荐基于git 源码安装包,暂时没发布pip 官方

参考资料

https://github.com/rongfengliang/sqlalchemy_dremio
https://github.com/narendrans/sqlalchemy_dremio

posted on 2024-03-29 08:00  荣锋亮  阅读(8)  评论(0编辑  收藏  举报

导航