使用sqlalchemy设置配置属性的正确方法?

时间:2017-08-09 13:48:58

标签: python hive sqlalchemy

我有一个脚本,它使用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> """)

我的上一次查询失败,查看日志我确定容器大小永远不会正确设置。是否有更好的方法可以动态更改会话变量?

1 个答案:

答案 0 :(得分:0)

似乎正确的方法是使用connect_args

找到here

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

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

相关问题