How to do bulk update / paste in mongoDb using pymongo / pandas. The error I get is batch op errors occurred I understand because I set the "_id" I want to make. I code works fine on the first run, but on the second run it fails. I want to use pandas in a workflow. Data has a datetime object.
The syntax is completely different for upsert = True , with Update . An efficient solution with Update would be useful, where "_id" or "qid" could be installed. But there are python datetime objects!
InSQL = 'SELECT * from database2.table2 ' sqlOut = pd.read_sql(InSQL,cxn) sqlOut['_id'] = "20170101" + ":"+ sqlOut['Var'] dfOut = sqlOut.to_json(orient='records',date_format='iso' ) try: db["test"].insert_many(json.loads(dfOut)) except Exception as e: print e
I gave 50 pt bounty which expired without response. Hm ...
source share