2017-08-09 129 views
0

我有一個腳本,使用PyHive和SQLAlchemy在Hive集羣上執行一些ETL。我工作的一部分是這樣的:使用sqlalchemy設置配置屬性的正確方法?

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> """) 

我最後的查詢失敗,看着我確定容器大小永遠不會設置正確的日誌。有沒有更好的方法來即時更改會話變量?

回答

0

看來,正確的方法是使用connect_args

找到here

create_engine(
    'hive://[email protected]:10000/database', 
    connect_args={'configuration': {'hive.exec.reducers.max': '123'}}, 
) 

有一個相應的configuration指令爲DB-API連接。