运行具有2条记录(GTIN号)的csv时出错。
> ERROR: pymongo.errors.DuplicateKeyError: E11000 duplicate key error
> collection: toys1_db.toys1 index: _id_ dup key: { :
> ObjectId('5c87bd626a1fcf2fd856a655') }
代码:
def mongo(self,product_dict):
myclient = pymongo.MongoClient("mongodb://localhost:27017/")
mydb = myclient["toys1_db"]
mycol = mydb["toys1"]
#mydict = product_dict
#mycol.drop()
#del my_dict['_id']
# print "First : ",mydict
mycol.insert_one(product_dict)