python链接Hive

之前一直用thrift链接Hive,但在运行时总出现问题,一直报缺少模块的错误,装了这个模块,又报缺少那个模块,连了半天,全是泪啊!

原来thrift链接Hive的.py文件后续没人维护,是连不上的。

果断放弃thrift,直接用impala,哈哈,终于连上了,我那个兴奋啊,你懂的。

需要的亲们,直接拿去用吧。

from impala.dbapi import connect
conn = connect(host="10.1.2.72", port=10000,database="moreqinrdb")########链接Hive
cursor = conn.cursor()
cursor.execute("SELECT * FROM COMPANY_BUSINESS_INFO")
results = cursor.fetchall()
colname=[]
coladdress=[]
colscope=[]
for data in results:
colname.append(data[0])
coladdress.append(data[12])
colscope.append(data[13])
print(coladdress,'\n')

坚持做自己,总有欣赏你的千里马!
原文地址:https://www.cnblogs.com/wyj690/p/5386905.html