要想使用python连接hive,首先得下载以下几个包:
pip install sasl
pip install thrift
pip install thrift-sasl
pip install PyHive
但是我们在安装sasl的时候可能会报错,导致安装不上,这个时候就得去
sasl下载地址
下载我们所需要的sasl,记得要和我们python版本匹配,我这里选择下载的是sasl‑0.2.1‑cp35‑cp35m‑win32.whl并存放到桌面。
然后打开cmd,进入Desktop目录输入: pip install sasl‑0.2.1‑cp35‑cp35m‑win32.whl (如果没安装wheel记得先安装wheel:
pip install wheel)
这样就能成功的安装PyHive了。
-
下面进行测试,测试代码如下
from pyhive import hive conn = hive.Connection(host='ip地址', port=10000, username='用户名', database='default') cursor = conn.cursor() cursor.execute('select * from testhive limit 10') for result in cu
版权声明:本文为a6822342原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。