①背景
windows+python3+连接已有hive集群且已经开启hiveserver2 服务
linux下用pyhive可能会方便一些,windows下pyhive需要在集群和连接代码中同时指定auth_mechanism参数,会影响到集群里的hue服务(我司使用的是CDH集群),因此建议在windows下使用impyla来连接
②正确安装方式
1.pip install pure-sasl
2.pip install thrift_sasl==0.2.1 --no-deps
3.pip install thrift==0.9.3
4.pip install thriftpy
5.pip install impyla
6.把\lib\site-packages\thrift_sasl\__init__.py第94行
...
header = struct.pack(">BI", status, len(body))
self._trans.write(header + body)
...
改为
...
header = struct.pack(">BI", status, len(body))
if(type(body) is str):
body = body.encode()
self._trans.write(header + body)
...
7.from impala.dbapi import connect
8.conn = connect(host='****',port=10000,auth_mechanism=&