更新时间:2023-02-14 11:45:19
可以手动构造一个 CQL
插入语句,遍历字典中的键和值,但 cqlengine
模型
可能比 dict
更适合使用,并且很容易使用中的值填充
。模型
c $ c> dict
You could manually construct a CQL
insert statement iterating over the keys and values in the dictionary, but a cqlengine
Model
is probably more appropriate to use than a dict
, and it is easy to populate a Model
with the values from the dict
.
您可以定义 Model
它与所有列):
You can define the Model
like so (extending it with all of your columns):
class CustomerEventsServiceEvent(Model):
__table_name__ = "customer_events_service.events"
acceptFirstContactDuration = columns.Decimal()
allSeenPageCount = columns.Decimal()
callAcceptedCount = columns.Decimal()
如果 d
是字典变量的名称,则
If d
is the name of your dictionary variable, then
event = CustomerEventsServiceEvent(**d)
event.save()
等同于您的MongoDB操作。
is the equivalent of your MongoDB operation.