Hello I am using SQLAlchemy and Flask-SQLAlchemy, and when I execute an insert with
camera = Camera(name=name, project_id=project.id, url=url)
db.session.add(camera)
db.session.commit()
And fails the insert because fail any constraint like unique name, the following insert Camera's id is jumped one over the previous.
+---------------------+---------------------+----+----------+------------------------+------------+
| created_at | updated_at | id | name | url | project_id |
+---------------------+---------------------+----+----------+------------------------+------------+
| 2022-05-11 13:52:21 | 2022-05-11 13:54:44 | 1 | Camera 1 | rtsp://localhost:8554/ | 1 |
| 2022-05-11 13:52:21 | 2022-05-11 13:55:12 | 3 | Camera 2 | rtsp://localhost:8554/ | 1 |
| 2022-05-11 13:52:21 | 2022-05-11 13:55:15 | 4 | Camera 3 | rtsp://localhost:8554/ | 1 |
+---------------------+---------------------+----+----------+------------------------+------------+
As you can see I did one wrong insert between the first and second records.
Why did this happened? How can I solved it?