How can I copy one collection from MongoDB using pymongo and paste to another empty collection?
问题 I want to copy full collection (e.g. name 'home'). Then do some changes in the 'home' collection or remove doc inside it (not a collection). And then replace changed 'home' collection to its default state from item 1. I do next: db = client["database"] home = db['home'].find() # get collection. db['home'].remove({}) # remove doc from home for i in home: self.db['home'].insert(i) But the collection is empty. 回答1: The problem with your code example is that find() returns a database cursor to