0

Within a plotly-dash application, I am entering some user-specified data into a mongoDB database.

The Issue: The first entry of the information is successful, however, any consecutive entries are not and a pymongo.errors.DuplicateKeyError is raised.

I am speculating that since mongodDB ObjectID() generation is done client-side, there is no refresh occurring since all aspects of this code for insert are done within a app.callback decorator within dash and are likely executed within a thread or separate process.

Shutting down the app and re-starting allows for the insertion of a new record.

The question: Is there a way to manually "refresh" the ObjectID generated within pymonngo? I would likely want to do this after an exception haldeing of DuplicateKeyError.

Avaricious_vulture
  • 1,114
  • 8
  • 10

1 Answers1

0

For anyone out there with this problem:

Simply have a new dict, placing dict['_id']= ObjectID() prior to insert, do not let mongodb handle it

Avaricious_vulture
  • 1,114
  • 8
  • 10