Search code examples
pythonmongodbbatch-insert

MongoDB with python bulk operations insert update


Is it possible to have a bulk operation in MongoDB (with python) where insert and update commands are mixed? Updated records can be the ones that would be inserted in the same batch.


Solution

  • Yes. PyMongo 2.7 added a "Bulk API" which you can read about here. PyMongo 3.0 is adding an alternative API to do the same thing that is very similar to what you mention in a comment to another answer. See this commit for a preview.