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中导入
- 下一篇: matlab状态空间程序,实验四用MAT