【问题标题】:How to connect with Hiveserver2 using Python 3.4.5如何使用 Python 3.4.5 连接 Hiveserver2
【发布时间】:2017-07-06 06:35:01
【问题描述】:

我需要从 Python 3.4.5 连接到 Hiveserver2,并且代码正在 hadoop 集群本身上执行。通常,我从命令行执行hive -e "some query"。从其他服务器,我们使用仅提供 IP 和端口的用户名机制连接到 Hiveserver2。但是,这不是必需的,因为我在同一台服务器上运行代码。

我尝试了以下方法:

  1. Access Hive Data Using Python
  2. https://github.com/cloudera/impyla/issues/165
  3. How to connect to Hadoop Hive through python via pyhs2?
  4. https://pypi.python.org/pypi/impyla

但没有成功。我在连接阶段本身出现错误。如果有人需要,我可以分享错误。

如果没有别的,如果有人能详细说明答案,那就太好了 Hive client for Python 3.x

【问题讨论】:

  • 包括一个演示问题和错误/跟踪的最小代码示例。

标签: python python-3.x hadoop hive python-3.4


【解决方案1】:

朋友的帮助和使用 impala.dbapi 稍微调整在线可用答案解决了这个问题:

from impala.dbapi import connect
conn = connect(host='localhost', port = 10000,auth_mechanism='PLAIN')
cursor = conn.cursor()
cursor.execute('show databases')
results = cursor.fetchall()
print(type(results))
print(results)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-08-24
    • 2023-03-31
    • 2015-05-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-10
    • 1970-01-01
    相关资源
    最近更新 更多