python中怎么利用pyhive连接hive,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。
首先安装pyhive
pip install pyhive
连接hive通过LDAP
connection = hive.connect(host='HIVE_HOST',
port=10000,
database='temp',
username='HIVE_USERNAME',
password='HIVE_PASSWORD',
auth='CUSTOM')
连接hive通过Kerberos
from pyhive import hive
connection = hive.connect(host='HIVE_HOST',
port=10000,
database='temp',
username='HIVE_USERNAME',
auth='KERBEROS',
kerberos_service_name='hive')
执行hive查询
query="select * from temp.test_table"
cur = connection.cursor()
cur.execute(query)
res = cur.fetchall()
看完上述内容,你们掌握python中怎么利用pyhive连接hive的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注天达云行业资讯频道,感谢各位的阅读!