python连接hive

Python连接hive,我使用pyhive。
以下安装流程如下:
1、创建虚拟环境(也可以不用创建,但建议创建安装):
conda create -n hiveconn python=3.6
2、进入虚拟环境下: conda activate hiveconn
3、使用conda安装以下两个包,如果用pip会失败:
conda install sasl
conda install thrift_sasl
4、安装pip install thrift,以及pip install PyHive
安装成功
下面如果用Python连接hive,代码如下:

from pyhive import hive
conn = hive.Connection(host='10.10.10.88', port=8008, username='***', password='*******', database='数据库名称', auth="CUSTOM")
cursor = conn.cursor()
cursor.execute('select * from Table')
for result in cursor.fetchall():
    print(result)

你可能感兴趣的:(python连接hive)