首页 > 编程语言 > 详细

python连接hive

时间:2020-02-14 15:16:00      阅读:46      评论:0      收藏:0      [点我收藏+]

参考:

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())

python连接hive

原文:https://www.cnblogs.com/hongfeng2019/p/12307496.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!