简体   繁体   English

使用 umongo 批量插入/更新

[英]Bulk insert/update with umongo

I would like to perform bulk insert/update with the umongo library in Python.我想使用 Python 中的 umongo 库执行批量插入/更新。 Is there a way to do the bulk update all at once or am I going to run one insert/update job per item to update ?有没有办法一次进行批量更新,还是我要为每个项目运行一个插入/更新作业来更新?

umongo doesn't do bulk update. umongo 不进行批量更新。

What you could do is call to_mongo on each document to build the bulk insert/update payload, then call YourDocument.collection.insert/update with that payload.您可以做的是在每个文档上调用to_mongo以构建批量插入/更新有效负载,然后使用该有效负载调用 YourDocument.collection.insert/update 。

Beware, the bulk insert/update operation is not atomic (independently from umongo).请注意,批量插入/更新操作不是原子的(独立于 umongo)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM