我有一个cassandra数据库,其键空间如下:
CREATE TABLE custumer_events_service.events(
acceptFirstContactDuration decimal,
currentTime timestamp,
visitorIdentifier text,
PRIMARY KEY (visitorIdentifier, currentTime)
) WITH CLUSTERING ORDER BY (currentTime DESC);
还有一个python dict
^{pr2}$有没有办法直接用cassandra-driver
插入这个dict?我在找类似mongodb的东西
>>> import datetime
>>> post = {"author": "Mike",
... "text": "My first blog post!",
... "tags": ["mongodb", "python", "pymongo"],
... "date": datetime.datetime.utcnow()}
>>> posts = db.posts
>>> post_id = posts.insert_one(post).inserted_id
您可以手动构造一个迭代字典中的键和值的} ^{} 可能比
CQL
insert语句,但是^{dict
更适合使用,而且很容易用dict
中的值填充Model
。在您可以像这样定义
Model
(用所有列扩展它):如果
^{pr2}$d
是dictionary变量的名称,则相当于您的MongoDB操作。在
相关问题 更多 >
编程相关推荐