pymongo includes methods to work with ObjectId() as other type.
You can see what they are in the docs here. You can probably make do with just str(o).
Question
I have a Large Mongo DB with raw web scraping data. I have a process that reads the mongo docs and creates records in my MySQL reporting DB. I need to track the documents that I have processed in the MongoDB. I am trying to use the ObjectID but can't seem to convert it to a string. I am using Pymongo as my client.
for i in Coll.find({"ISBN": {"$exists" : True}})[20:50]:
print('starting collection loop')
#Check if doc has been processed
if not ProcessingLog.objects.filter(mongoID = i['_id']).exists():
mongoID = ProcessingLog(mongoID = i['_id'],source = 'amazon',createDate= datetime.datetime.now())
....
I get the following error
ValueError: too many values to unpack
Solution
pymongo includes methods to work with ObjectId() as other type.
You can see what they are in the docs here. You can probably make do with just str(o).