【问题标题】:Correct way to set configuration properties with sqlalchemy?使用 sqlalchemy 设置配置属性的正确方法?
【发布时间】:2017-08-29 21:30:44
【问题描述】:

我有一个脚本,它使用PyHive 和 SQLAlchemy 在 Hive 集群上执行一些 ETL。我的一部分工作如下所示:

hivecon = hive_engine.raw_connection()
hivecur = hivecon.cursor()

...

hivecur.execute(""" <some query> """)
hivecur.execute(""" set hive.tez.container.size=5120 """)
hivecur.execute(""" <some other query> """)

我的最后一个查询失败,查看日志我确定容器大小从未正确设置。有没有更好的方法来动态更改会话变量?

【问题讨论】:

    标签: python hive sqlalchemy


    【解决方案1】:

    看来正确的做法是使用connect_args

    找到here:

    create_engine(
        'hive://user@host:10000/database',
        connect_args={'configuration': {'hive.exec.reducers.max': '123'}},
    )
    

    有一个对应的configuration 指令用于 DB-API 连接。

    【讨论】:

      猜你喜欢
      • 2012-01-18
      • 2018-09-29
      • 2022-10-30
      • 2019-04-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-19
      • 2019-07-10
      相关资源
      最近更新 更多