首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >无法使用'put'()将数据添加到happybase的hbase中

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

Stack Overflow用户
提问于 2020-05-20 00:21:51
回答 1查看 307关注 0票数 0

我的python版本是3.7,在我运行pip3 install happybase之后,我启动了命令hbase thrift start,并尝试编写一个简短的.py文件,如下所示:

代码语言:javascript
运行
复制
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中的一切都是正常的,所以我找不到哪里出了问题,我要崩溃了。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-06-22 23:57:35

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

代码语言:javascript
运行
复制
table.put('001:', {'title':'dasds'}) 

此外,在第二次运行脚本后,您会看到不同的错误消息,因为thrift服务器已经出现故障。

我希望它能对你有所帮助。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61895941

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档