Pyhive Kerberos 连接问题

问题描述

使用 Python pyhive 模块连接到配置了 Kerberoshive 数据库时出现以下错误

kerberos_service_name should be set if and only if in KERBEROS mode

我的连接代码

import hive from pyhive

con = hive.Connection(host="hostnamexxxxx",port=10001,database="db_namexxxx",username="usernamexxxx",auth="KERBEROS",kerberos_service_name="hive")

完整的错误跟踪:

 File "/xx/xx/site-packages/pyhive/hive.py",line 126,in __init__
    raise ValueError("kerberos_service_name should be set if and only if in KERBEROS mode")
ValueError: kerberos_service_name should be set if and only if in KERBEROS mode

还尝试将 kerberos_service_name 更改为“attuid@principal”,但没有成功。

你能帮忙吗! 提前致谢

解决方法

正在进一步排除错误,错误在线上出现。

if (kerberos_service_name is not None) != (auth == 'KERBEROS'): raise ValueError("kerberos_service_name should be set if and only if in KERBEROS mode")

所以检查 auth 输出,当我从配置解析器获取身份验证值时,它在单词“KERBEROS”中包含引号,因此在比较时返回 false带有字符串 'KERBEROS'

即'KERBEROS' == ''KERBOROS''