pip install pyhive
connection = hive.connect(host='HIVE_HOST', port=10000, database='temp', username='HIVE_USERNAME', password='HIVE_PASSWORD', auth='CUSTOM')
鏈接hive經過Kerberospython
from pyhive import hive connection = hive.connect(host='HIVE_HOST', port=10000, database='temp', username='HIVE_USERNAME', auth='KERBEROS', kerberos_service_name='hive')
執行hive查詢fetch
query="select * from temp.test_table" cur = connection.cursor() cur.execute(query) res = cur.fetchall()