python3+pyhive访问hive

pip3 install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple
yum install gcc-c++
yum install gcc libffi-devel python-devel openssl-devel -y
yum -y install cyrus-sasl cyrus-sasl-devel cyrus-sasl-lib

pip3 install sasl -i https://pypi.tuna.tsinghua.edu.cn/simple
pip3 install thrift -i https://pypi.tuna.tsinghua.edu.cn/simple
pip3 install thrift-sasl -i https://pypi.tuna.tsinghua.edu.cn/simple
pip3 install PyHive -i https://pypi.tuna.tsinghua.edu.cn/simple

from pyhive import hive
conn = hive.Connection(host='node1', port=10000, username='hdfs', database='default')
cursor = conn.cursor()
cursor.execute('show tables')

for result in cursor.fetchall():
print(result)

posted @ 2020-03-04 21:31  舟山渔夫  阅读(1037)  评论(0编辑  收藏  举报