
大数据存储nosql;根据描述编写相应命令语句操作hbase数据库
关注引自免费微信小程序:皆我百晓生
book 的表,列族为 infohbase shell
create 'book', 'info'
book 表中增加列族 extra, 版本号为 3alter 'book', ADD COLUMN FAMILY 'extra', VERSIONS => 3
book 表的 info 列族put 'book', 'book1', 'info:bookname', '大数据存储'
put 'book', 'book1', 'info:author', '赵军'
put 'book', 'book1', 'info:price', '100'
put 'book', 'book2', 'info:bookname', '面向对象程序设计'
put 'book', 'book2', 'info:author', '李峰'
put 'book', 'book2', 'info:price', '59'
book 表中 rowkey 为 “book1” 的价格为 69put 'book', 'book1', 'info:price', '69'
book 表中所有书名和价格,并格式化字符串scan 'book', {COLUMNS => 'info:bookname,info:price'}
然后你需要在客户端进行字符串的格式化处理。
book 表中 rowkey 为 “book2” 的所有数据deleteall 'book', 'book2'
book 表中 rowkey 为 “book1” 的作者字段delete 'book', 'book1', 'info:author'
from pymongo import MongoClient
client = MongoClient('192.168.0.125', 27018)
db = client.kk
collection = db.luntan
comments = [
{"id": 1, "name": "云海", "content": "这几天郑州真热"},
{"id": 2, "name": "话梅", "content": "刚过端午,河南都这么热了"},
{"id": 3, "name": "君君", "content": "过几天更热,河南农民太难了"}
]
collection.insert_many(comments)
new_comment = {"id": 4, "name": "lili", "content": "河南高温上热搜了"}
collection.insert_one(new_comment)
comment = collection.find_one({"name": "lili"})
print(comment["name"], comment["content"])
collection.update_one({"id": 2}, {"$set": {"content": "河南真热"}})
collection.delete_one({"id": 4})
comments = collection.find({"id": {"$gte": 1, "$lte": 3}})
for comment in comments:
print(comment)
以上代码应能完成你提出的所有任务。