如何使用python pyhs2连接到hive?

时间:2015-08-21 12:59:07

标签: python hadoop hive thrift

我正在尝试使用pyhs2访问配置单元。我尝试了以下代码:

example.py

import pyhs2
conn = pyhs2.connect(host='localhost', port=10000,authMechanism=None, user=None, password=None,database='default')
with conn.cursor() as cur:
        cur.execute("select * from table")
        for i in cur.fetch():
            print i

我收到以下错误:

    Traceback (most recent call last):
 File "example.py", line 2, in <module> conn = pyhs2.connect(host='localhost', port=10000,authMechanism=None, user=None, password=None,database='default')
      File "build/bdist.linux-x86_64/egg/pyhs2/__init__.py", line 7, in connect
      File "build/bdist.linux-x86_64/egg/pyhs2/connections.py", line 46, in __init__
      File "build/bdist.linux-x86_64/egg/pyhs2/cloudera/thrift_sasl.py", line 55, in open
      File "build/bdist.linux-x86_64/egg/thrift/transport/TSocket.py", line 101, in open
    thrift.transport.TTransport.TTransportException: Could not connect to localhost:10000

当我尝试使用hive utils时,我收到了确切的错误。我检查了sasl安装。我是否需要对配置单元中的hive-site.xml进行任何更改?如果是,我需要在哪里创建它?我错过了什么吗?

0 个答案:

没有答案