【发布时间】:2016-05-30 22:15:22
【问题描述】:
我有一个 cassandra 数据库,其键空间如下所示:
CREATE TABLE custumer_events_service.events(
acceptFirstContactDuration decimal,
currentTime timestamp,
visitorIdentifier text,
PRIMARY KEY (visitorIdentifier, currentTime)
) WITH CLUSTERING ORDER BY (currentTime DESC);
还有一个 python 字典
{u'acceptFirstContactDuration': 0,
u'currentTime': u'2016-02-18T11:51:55.468Z',
u'12eca72928845aae26268f431b8c75b2564d7919c916e',}
有没有办法直接用cassandra-driver 插入这个字典?我正在寻找类似 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
【问题讨论】:
标签: python mongodb dictionary cassandra nosql