我正在使用happybase连接到我的Hbase数据库。我做了一个叫做“irisSample”的样本表。这是我遇到麻烦的部分代码-
import happybase
from happybase import *
import json
connection = happybase.Connection('<ip-address>', '9090')
table = connection.table('irisSample')
n = 0
x = 1
for u in y:
data = {'petalWidth':points['petalWidth'][n], 'sepalLength':points['sepalLength'][n],
'petalLength':points['petalLength'][n], 'label': u}
row = 'row' + str(x)
table.put(row, {'flowers': str(data)})
n += 1
x += 1
我得到以下结论。在
^{pr2}$我还尝试了json.dumps(data)
,而不是引发相同异常的str(data)
。在
从我收集的资料来看,这更像是一个节俭问题,但我可能错了。我可能得去看看星际基地。我不知道,所以我才问你们。在
看起来在你的“data”对象中,你没有给出列族和列名。在
每个列值之前都需要有列族。E、 例如,假设你的列族是“cf”,那么你想要的不是“petalWidth”,而是“cf:petalWidth”。在
^{pr2}$这样做修复了mutateRows错误。在
我找到了答案here。它要求REST框架在未使用的端口上运行。然后连接到该端口,可以看到Hbase中所有表的列表,并将数据插入数据库。命令是
./hbase-daemon.sh start rest -p <unused port number>
。我在任何地方都找不到答案,甚至有几天没有人发表评论,所以我希望这对你有帮助!这是密码。最后我使用了starbase
。在8000是默认端口。在
^{pr2}$相关问题 更多 >
编程相关推荐