I'm trying to backup some data that i stored on a collection to another collection hosted on a single db. I came up with a very simple solution, which works but very slowly, so i was trying to find a faster way to do this. Here is what i tried:
def updater():
COL1= DB1.WData.find({})
for x in COL1:
Values = {"$set": {"datetime": x['datetime'], "amount": x['amount']}}
Query = {"datetime": x['datetime'], "price": x['price']}
DB2['COL2'].update_one(Query, Values, upsert=True)
As i said, this works but very slowly; and since i have around 23k records i was trying to find a way to speed it up. Any advice is appreciated