24412-Python链接LDAP(Kerbores)认证的Impala

24412-Python链接LDAP(Kerbores)认证的Impala

必须安装pyImpala才行

pip install impyla

Python3.x 链接LDAP(Kerbores)认证的Impala代码

from impala.dbapi import connect

impala_host = "172.10.194.101"
impala_port = "25004"
impala_user = 'huabingood_test'
impala_pwd = '666666'

# 创建pyimpala链接
def getDataFromImpala(sql: str):
    print("当前向impala查询的是:\n" + sql)
    conne = connect(host=impala_host, port=impala_port, auth_mechanism='LDAP', user=impala_user, password=impala_pwd,
                    timeout=600, retries=6)
    cur = conne.cursor()
    cur.execute(sql)
    res = cur.fetchall()
    return res

if __name__ == "__main__":
    sql = "show tables in sdata;"
    res = getDataFromImpala(sql)
    print(res)

posted @ 2024-08-04 22:20  huabingood  阅读(1)  评论(0编辑  收藏  举报