python3使用kerberos认证连接hive

from impala.dbapi import connect
from krbcontext import krbcontext
with krbcontext(using_keytab=True,principal='vspread',keytab_file='keytab路径'):
   conn = connect(host="IP or 域名", port=端口, auth_mechanism='GSSAPI', kerberos_service_name='hive',database='数据库名')
   cursor = conn.cursor()
   cursor.execute("sql")
   data = cursor.fetchall()
   print (data)
   cursor.close()
   conn.close()

 

posted @ 2022-07-16 14:43  隔壁Mr.Wang  阅读(1226)  评论(0编辑  收藏  举报