参考:
https://blog.csdn.net/a6822342/article/details/80713652 #简单
https://www.zhihu.com/question/269333988 #复杂点的
deactivate
sudo -i
. /mnt/disk1/data/venv_bi/bin/activate
pip install pyhive
pip install thrift
pip install sasl
pip install thrift_sasl
vim h.py
from pyhive import hive
conn = hive.Connection(host=‘127.0.0.1‘, port=10000, username=‘feng.hong‘, database=‘test_db‘)
cursor = conn.cursor()
cursor.execute(‘show databases‘)
print(cursor.fetchall())
或使用select查询
conn = hive.Connection(host=‘127.0.0.1‘, port=10000, username=‘feng.hong‘, database=‘test_db‘)
cursor = conn.cursor()
cursor.execute(‘select * from users limit 10‘)
print(cursor.fetchall())
原文:https://www.cnblogs.com/hongfeng2019/p/12307496.html