Flask: PK Violations Using flask-sqlalchemy Flask: PK Violations Using flask-sqlalchemy flask flask

Flask: PK Violations Using flask-sqlalchemy


You have two options:

  1. Catch the PK violation and react accordingly, like you already said.

  2. Lock your transaction based on your id: this is more complicated, you need something to synchronize your locks, like redis. Take a look at python-redis-lock. It is just one option, the solution here is to avoid concurrency for a PK.

https://pypi.python.org/pypi/python-redis-lock