TSocket读取0字节使用python

时间:2017-06-25 11:07:04

标签: python api hadoop hive thrift

我正在尝试连接Hive以在嵌入式/伪模式下使用pyhive获取一些表。以下是我用过的代码

#!/usr/bin/env python
# coding: utf-8
from pyhive import hive
from TCLIService.ttypes import TOperationState
def mysql_connect(host, port, username):
 conn = hive.Connection(host=host, port=port, username=username)
 return conn.cursor()
cursor = mysql_connect("localhost", 50070, "hduser")
cursor.execute("show databases")
print_log(cursor)

输出:我不知道为什么我会收到此错误以及如何解决此问题

vaibhav@vaibhav-Lenovo-G570:~/Desktop/Python/Automation$ ./pyhive_test.py
Traceback (most recent call last):
  File "./pyhive_test.py", line 9, in <module>
    cursor = mysql_connect("localhost", 50070, "hduser")
  File "./pyhive_test.py", line 6, in mysql_connect
    conn = hive.Connection(host=host, port=port, username=username)
  File "/usr/local/lib/python2.7/dist-packages/pyhive/hive.py", line 131, in __init__
    self._transport.open()
  File "/usr/local/lib/python2.7/dist-packages/thrift_sasl/__init__.py", line 80, in open
    status, payload = self._recv_sasl_message()
  File "/usr/local/lib/python2.7/dist-packages/thrift_sasl/__init__.py", line 101, in _recv_sasl_message
    payload = read_all_compat(self._trans, length)
  File "/usr/local/lib/python2.7/dist-packages/thrift_sasl/six.py", line 31, in <lambda>
    read_all_compat = lambda trans, sz: trans.readAll(sz)
  File "/home/vaibhav/.local/lib/python2.7/site-packages/thrift/transport/TTransport.py", line 60, in readAll
    chunk = self.read(sz - have)
  File "/home/vaibhav/.local/lib/python2.7/site-packages/thrift/transport/TSocket.py", line 132, in read
    message='TSocket read 0 bytes')
thrift.transport.TTransport.TTransportException: TSocket read 0 bytes

0 个答案:

没有答案