python使用pyhive链接hive

首先安装pyhive

pip install pyhive

链接hive经过LDAP

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()
相关文章
相关标签/搜索