簡體   English   中英

無法使用pyhive連接到配置單元

[英]unable to connect to hive using pyhive

連接刪除hiveserver2時出現“ EOFError()”錯誤。 我的pyhive版本是0.6.1

hiveserver2使用http作為傳輸模式

這是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()

這也是我用來連接以刪除配置單元的代碼

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有一個簡單的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