【python 连接hive】python 连接hive

一、需要安装模块

pip install sasl
pip install thrift
pip install thrift-sasl
pip install pyhive

Thrift,sasl 要求最新版本

二、代码模块

# -*- encoding=utf-8 -*-
import time
time1=time.time()
import pandas as pd
from pyhive import  hive

cursor=hive.connect(host='XXXXXXXXXXXX',port='10000',username='dongli').cursor()



sql="""


此处放sql脚本

"""
cursor.execute(sql)

data=pd.DataFrame(cursor.fetchall())

print(data.head())


time2 = time.time()
print('总共耗时:' + str(time2 - time1) + 's')

猜你喜欢

转载自blog.csdn.net/u013421629/article/details/81384806