无法使用'put'()将数据添加到happybase的hbase

egmofgnx  于 2021-05-31  发布在  Hadoop
关注(0)|答案(1)|浏览(916)

我的python版本是3.7 pip3 install happybase ,我启动了命令 hbase thrift start 并尝试编写一个简短的.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()

当它要跑的时候 table.put() ,它报告了这样一个错误: thriftpy2.transport.base.TTransportException: TTransportException(type=4, message='TSocket read 0 bytes') 同时 thrift 报告错误: ERROR [thrift-worker-1] thrift.TBoundedThreadPoolServer: Error occurred during processing of message. java.lang.IllegalArgumentException: Invalid famAndQf provided. 但是刚才我再次运行了这个python文件,它给了我一个不同的错误 thrift : thrift.TBoundedThreadPoolServer: Thrift error occurred during processing of message. org.apache.thrift.protocol.TProtocolException: Bad version in readMessageBegin 我尝试添加如下参数 protocol='compact', transport='framed' ,但这不起作用,甚至 table.scan() 失败。世界上的一切 hbase shell 还好,所以我搞不清楚出了什么问题,我快要崩溃了。

nnsrf1az

nnsrf1az1#

我遇到了同样的问题,找到了这个解决方案。您需要在put()方法中添加空列限定符(“:”符号作为列族和列限定符之间的分隔符):

table.put('001:', {'title':'dasds'})

另外,在第二次运行脚本之后,您会收到不同的错误消息,因为thrift服务器已经失败。
我希望它能帮助你。

相关问题