我想从python连接蜂巢。 为了测试,我在Pycharm中创建了以下脚本,并尝试连接配置单元
from pyhive import hive
import sys
import pandas as pd
import ssl
import thrift_sasl
con=hive.Connection(host="ip_addrs",port=10000,username="hiveuser_test", auth='NOSASL')
cursor = con.cursor()
print(cursor.fetchall())
print(con)
在运行代码时出现以下错误:
C:\Users\username_dim\AppData\Local\Programs\Python\Python36-32\python.exe C:/Users/username_dim/PycharmProjects/untitled1/Test
Traceback (most recent call last):
File "C:/Users/username_dim/PycharmProjects/untitled1/Test", line 11, in <module>
con=hive.Connection(host="ip_addres",port=10000,username="hiveuser_test", auth='NOSASL')
File "C:\Users\username_dim\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyhive\hive.py", line 198, in __init__
response = self._client.OpenSession(open_session_req)
File "C:\Users\username_dim\AppData\Local\Programs\Python\Python36-32\lib\site-packages\TCLIService\TCLIService.py", line 187, in OpenSession
return self.recv_OpenSession()
File "C:\Users\username_dim\AppData\Local\Programs\Python\Python36-32\lib\site-packages\TCLIService\TCLIService.py", line 199, in recv_OpenSession
(fname, mtype, rseqid) = iprot.readMessageBegin()
File "C:\Users\username_dim\AppData\Local\Programs\Python\Python36-32\lib\site-packages\thrift\protocol\TBinaryProtocol.py", line 148, in readMessageBegin
name = self.trans.readAll(sz)
File "C:\Users\username_dim\AppData\Local\Programs\Python\Python36-32\lib\site-packages\thrift\transport\TTransport.py", line 60, in readAll
chunk = self.read(sz - have)
File "C:\Users\username_dim\AppData\Local\Programs\Python\Python36-32\lib\site-packages\thrift\transport\TTransport.py", line 162, in read
self.__rbuf = BufferIO(self.__trans.read(max(sz, self.__rbuf_size)))
File "C:\Users\username_dim\AppData\Local\Programs\Python\Python36-32\lib\site-packages\thrift\transport\TSocket.py", line 132, in read
message='TSocket read 0 bytes')
thrift.transport.TTransport.TTransportException: TSocket read 0 bytes
Process finished with exit code 1
Core-site.xml
我曾经配置过hiveserver2
<property>
<name>hadoop.proxyuser.sqoop2.hosts</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.sqoop2.groups</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.hiveuser_test.hosts</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.hiveuser_test.groups</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.server.hosts</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.server.groups</name>
<value>*</value>
</property
> Blockquote
请帮助我纠正错误
答案 0 :(得分:1)
cursor.execute(“ SELECT ....”)丢失。这就是为什么您的节俭连接无法读取任何数据async function submit_reset_password_request (request, response) {
if(request.session.id) {
return response.json({ error: true, message: 'password reset cannot be requested during an sctive session' });
}
const { email } = request.body;
if(email) {
email = email.toLowerCase().trim();
}
if(!email) {
return response.json({ error: true, message: 'input is required' });
}
try {
const user_result = await models.Users.findOne({ where: { email } });
if(!user_result) {
return response.json({ error: true, message: 'No account found by that email' });
}
const user = user_result.dataValues;
const request_result = await models.ResetPasswordRequests.findOne({ where: { user_email: user.email } });
if(request_result) {
return response.json({ error: true, message: 'A password reset has already been requested for this email' });
}
const new_reset_request = await models.ResetPasswordRequests.create({ user_email: user.email });
const reset_request = new_reset_request.dataValues;
// send reset request email
const host = request.get('host');
const link = host.endsWith('/') ? (host + 'search') : (host + '/search');
const email_subject = 'Epsity - Password reset requested';
const email_html = templateEngine.PasswordReset_EMAIL({ user, reset_request, link });
const email_result = await sendgrid_manager.send_email(null, request.session.you.email, email_subject, email_html);
return response.json({ success: true, message: 'A password reset request has been sent to the provided email!' });
} catch(error) {
console.log(error);
return response.json({ error, message: 'Could not sumbit reset password request...' });
}
}
修改后的代码如下。
thrift.transport.TTransport.TTransportException: TSocket read 0 bytes
注意:根据需要替换此行。 select_stmt ='SELECT * FROM t1 LIMIT 10'