使用pyhive连接hive后,可以直接保存为数据框
import sys
import pandas as pd
from pyhive import hive
username = 'xxx'
password = 'yyy'
queue = '队列名'
conn = hive.connect(
host='#ip',
port=9999,
username=username,
password=password,
auth='LDAP',
configuration={"""mapreduce.job.queuename""": queue})
sql = """
select * from table limit 1
"""
df = pd.read_sql_query(sql,conn)