irpas技术客

Python Anaconda安装sasl,thrift,thrift-sasl 并连接PyHive_从零开始的数据猿_python sasl

网络 5490

安装包版本说明

python: 3.6 / 3.7 / 3.8 pyhive: 0.6.2 thrift: 0.13.0 thrift_sasl: 0.4.2 sasl: 根据python version决定

一,到https://·/dropbox/PyHive/tree/v0.6.2 第一种测试:(可能会报错,请使用第二种,详情请看github Pyhive)

from pyhive import hive conn = hive.Connection(host='lylg102', port=10000, auth="NONE", database='default', username='lylg') cursor = conn.cursor() cursor.execute('SELECT * from students') for result in cursor.fetchall(): print(result) cursor.close() conn.close()

第二种测试:

from pyhive import hive from TCLIService.ttypes import TOperationState def execute_sql(query): hive.connect('lylg102', configuration={'hive.exec.reducers.max': '123'}) cursor = hive.Connection(host='lylg102', port=10000, auth='NONE', database='default', username='lylg').cursor() cursor.execute(query, async_=True) status = cursor.poll().operationState while status in (TOperationState.INITIALIZED_STATE, TOperationState.RUNNING_STATE): status = cursor.poll().operationState res = cursor.fetchall() cursor.close() return res if __name__ == '__main__': sql = '\ select avg(views), \ avg(score), \ sum(views) from cartoon_info' res = execute_sql(sql) print(res)

参考:https://its401.com/article/weixin_34232617/93727029 https://github.com/dropbox/PyHive/issues/240


1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,会注明原创字样,如未注明都非原创,如有侵权请联系删除!;3.作者投稿可能会经我们编辑修改或补充;4.本站不提供任何储存功能只提供收集或者投稿人的网盘链接。

标签: #Python #sasl #安装包版本说明python #36 #37 #38pyhive