[英]Can't use 'put'() to add data to hbase with happybase
My python version is 3.7, and after I ran pip3 install happybase
, I started the command hbase thrift start
and tried to write a brief.py file as following:我的 python 版本是 3.7,在我运行
pip3 install happybase
,我启动了命令hbase thrift start
并尝试编写如下的 brief.py 文件:
import happybase
connection = happybase.Connection('master')
table = connection.table('jmlr') #'jmlr' is a table in hbase
for i in table.scan():
print(i)
table.put('001', {'title':'dasds'}) #error here
connection.close()
When it's about to run table.put()
, it reported such an error:当它即将运行
table.put()
时,它报告了这样一个错误:
thriftpy2.transport.base.TTransportException: TTransportException(type=4, message='TSocket read 0 bytes')
And at the same time, the thrift
reported an error:并且同时
thrift
报错:
ERROR [thrift-worker-1] thrift.TBoundedThreadPoolServer: Error occurred during processing of message. java.lang.IllegalArgumentException: Invalid famAndQf provided.
But just now I ran this python file again, it gave me a different error in thrift
:但是刚才我再次运行了这个 python 文件,它在
thrift
中给了我一个不同的错误:
thrift.TBoundedThreadPoolServer: Thrift error occurred during processing of message. org.apache.thrift.protocol.TProtocolException: Bad version in readMessageBegin
I have tried to add parameters like protocol='compact', transport='framed'
, but this didn't work, even the table.scan()
failed.我曾尝试添加诸如
protocol='compact', transport='framed'
类的参数,但这不起作用,甚至table.scan()
也失败了。 Everything in the hbase shell
is OK, so I can't figure out what went wrong, I'm about to collapse. hbase shell
的一切都OK,所以想不通是哪里出了问题,快崩溃了。
I ran into the same issue and found this sollution.我遇到了同样的问题并找到了这个解决方案。 You need to add even empty Column Qualifier ( ':' symbol as delimiter between Column Family and Column Qualifier) into put() method:
您甚至需要在 put() 方法中添加空的列限定符(':' 符号作为列族和列限定符之间的分隔符):
table.put('001:', {'title':'dasds'})
Also, you have a different error message after second run of script because thrift server is already failed.此外,在第二次运行脚本后,您会收到不同的错误消息,因为 thrift 服务器已经失败。
I hope it will help you.我希望它会帮助你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.