简体   繁体   English

无法使用pyhive连接到配置单元

[英]unable to connect to hive using pyhive

I am getting "EOFError()" error while connecting to remove hiveserver2. 连接删除hiveserver2时出现“ EOFError()”错误。 My pyhive version is 0.6.1 我的pyhive版本是0.6.1

hiveserver2 is using http as the transport mode hiveserver2使用http作为传输模式

This is the exception ile "<stdin>", line 1, in <module> File "/usr/local/lib/python2.7/dist-packages/pyhive/hive.py", line 94, in connect return Connection(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/pyhive/hive.py", line 198, in __init__ response = self._client.OpenSession(open_session_req) File "/usr/local/lib/python2.7/dist-packages/TCLIService/TCLIService.py", line 187, in OpenSession return self.recv_OpenSession() File "/usr/local/lib/python2.7/dist-packages/TCLIService/TCLIService.py", line 199, in recv_OpenSession (fname, mtype, rseqid) = iprot.readMessageBegin() File "/usr/local/lib/python2.7/dist-packages/thrift/protocol/TBinaryProtocol.py", line 148, in readMessageBegin name = self.trans.readAll(sz) File "/usr/local/lib/python2.7/dist-packages/thrift/transport/TTransport.py", line 65, in readAll raise EOFError() 这是ile "<stdin>", line 1, in <module> File "/usr/local/lib/python2.7/dist-packages/pyhive/hive.py", line 94, in connect return Connection(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/pyhive/hive.py", line 198, in __init__ response = self._client.OpenSession(open_session_req) File "/usr/local/lib/python2.7/dist-packages/TCLIService/TCLIService.py", line 187, in OpenSession return self.recv_OpenSession() File "/usr/local/lib/python2.7/dist-packages/TCLIService/TCLIService.py", line 199, in recv_OpenSession (fname, mtype, rseqid) = iprot.readMessageBegin() File "/usr/local/lib/python2.7/dist-packages/thrift/protocol/TBinaryProtocol.py", line 148, in readMessageBegin name = self.trans.readAll(sz) File "/usr/local/lib/python2.7/dist-packages/thrift/transport/TTransport.py", line 65, in readAll raise EOFError()的异常ile "<stdin>", line 1, in <module> File "/usr/local/lib/python2.7/dist-packages/pyhive/hive.py", line 94, in connect return Connection(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/pyhive/hive.py", line 198, in __init__ response = self._client.OpenSession(open_session_req) File "/usr/local/lib/python2.7/dist-packages/TCLIService/TCLIService.py", line 187, in OpenSession return self.recv_OpenSession() File "/usr/local/lib/python2.7/dist-packages/TCLIService/TCLIService.py", line 199, in recv_OpenSession (fname, mtype, rseqid) = iprot.readMessageBegin() File "/usr/local/lib/python2.7/dist-packages/thrift/protocol/TBinaryProtocol.py", line 148, in readMessageBegin name = self.trans.readAll(sz) File "/usr/local/lib/python2.7/dist-packages/thrift/transport/TTransport.py", line 65, in readAll raise EOFError()

Also here is the code I am using to connect to remove hive 这也是我用来连接以删除配置单元的代码

from pyhive import hive
from thrift.transport import THttpClient
host = 'xxx'
scheme = 'http'
path = '/cliservice'
port = ':' + str(10001)
http_uri = "{}://{}{}{}".format(scheme, host, port, path)
transport = THttpClient.THttpClient(http_uri)

username = 'xxx'
password = ''
if username or password:
    auth = base64.b64encode(username + ':' + password)
    transport.setCustomHeaders({'Authorization': 'Basic ' + auth})
connection = hive.connect(thrift_transport=transport)

pyhive has a simple connect method, did you give if a try. pyhive有一个简单的connect方法,您是否尝试过?

from pyhive import hive
connection = hive.connect(host='HIVE_HOST',
                          port=10000,
                          database='temp',
                          username='HIVE_USERNAME',
                          password='HIVE_PASSWORD',
                          auth='CUSTOM')    

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM