如何在Impyla连接中提供用户和密码

问题描述 投票:2回答:3

我正在尝试从python连接impala并使用Impyla模块实现此目的。以下是用于连接的代码段。

connect(host='<impala_host>', port=21050)

当我尝试执行任何查询时,这与Authorization异常失败。确切的例外是,

impala.error.HiveServer2Error: AuthorizationException: User '<user>' does not have privileges to execute 'SELECT' on: <table>

如何为connect方法提供用户和密码?

python-2.7 python-module
3个回答
1
投票

看看代码,似乎userpassword参数默认设置为None。您应该能够使用以下内容自行设置它们:

connect(host='my.impala.host', port=21050, user='myuser', password='mypassword')

你可以在这里看到https://github.com/cloudera/impyla/blob/master/impala/dbapi.py的文档。


0
投票

我遇到过同样的问题。通过添加use_ssl解决了这个问题:

connect(host='my.impala.host', port=21050, user='myuser', password='mypassword', use_ssl=True)

0
投票

用户名可以在游标参数中定义,例如

conn = connect(host='myhost');
cursor = conn.cursor(user='myuser')
cursor.execute('select user();')
© www.soinside.com 2019 - 2024. All rights reserved.