2021-04-07
閱讀量:
518
如何使用Python連接hive
安裝依賴
pip install sasl
pip install thrift
pip install thrift-sasl
pip install PyHive
腳本示例
from pyhive import hive
HOST="127.0.0.1"
PORT=10000
USERNAME="hadoop"
DATABASE="default"
conn=hive.Connection(host=HOST, port=PORT, username=USERNAME,database=DATABASE)
cursor = conn.cursor()
#cursor.execute("INSERT INTO TABLE test_out(name,count,time) SELECT name,count(1),to_date(time) FROM test GROUP BY name,to_date(time)")
cursor.execute("SELECT * FROM test")
for result in cursor.fetchall():
print(result[2])






評(píng)論(0)


暫無數(shù)據(jù)
CDA考試動(dòng)態(tài)
CDA報(bào)考指南
推薦帖子
0條評(píng)論
0條評(píng)論
0條評(píng)論
0條評(píng)論