![](/img/trans.png)
[英]how to get Python Mongo Aggregate explain using db.command?
[英]python mongo db aggregate query for taking backup
在以前的一篇文章中,建議使用db[collection].aggregate([{'$match': {}}, {'$out': collection + timestamp}])
來備份集合。 但這正在創建一個臨時集合。
我想以python格式使用以下查詢。
db.collection1.find().forEach(function(d){db.collection2.save(d)})
謝謝,
這是您在python中進行復制的方式:
from pymongo import MongoClient
client = MongoClient()
db = client.yourDBname
n = 0
for r in db.sourceCollection.find():
db.targetCollection.insert(r)
n += 1
print "copied",n,"items"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.