python连接hive--Pyhive
生活随笔
收集整理的这篇文章主要介绍了
python连接hive--Pyhive
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
Pyhive
安装包
pip install sasl pip install thrift pip install thrift-sasl pip install PyHive # 安装对应的包 sasl可能会报错 #下载sasl文件sasl下载
执行语句
第一种
from pyhive import hive def select_pyhive(sql):# 创建hive连接conn = hive.Connection(host='##', port=##, username='##', database='库名')cur = conn.cursor()try:# c = cur.fetchall()df = pd.read_sql(sql, conn)return dffinally:if conn:conn.close() sql='select * from table limit 10' df = select_pyhive(sql)第二种
from sqlalchemy.engine import create_engine def _sql_hive():engine = create_engine('aaaaa://host:port/hive/')df = pd.read_sql("""select * from table limit 100""", engine)return df df = _sql_hive()总结
以上是生活随笔为你收集整理的python连接hive--Pyhive的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: AD19生成PCB_在Altium中导入
- 下一篇: python下载pyhive包: