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()