Koen Bok wrote: > Hello, I have two questions concerning sequences. > > Whenever an INSERT fails and a ROLLBACK occurs, the sequence is skipped > by one. What is the best way to prevent this? I could do a SELECT > max(id) FROM table and reset the sequence with it by making a trigger on > the table. But I don't think this will work while sqlachemy does a > SELECT nextval() before it inserts. > > There starts my second question. As I understand it, sqlalchemy submits > a new id by first selecting one from the sequence. But what if between > these two queries the same id was given to another client? That would > result in an error and therefore a ROLLBACK right? Is there a way to do > this on a database level? > > PS. I use Postgres, I don't know how this works for other databases.
It's not for Postgres, but maybe this article will help to get you going: http://www.ibobjects.com/TechInfo.html#ti_AuditableSeries Uwe _______________________________________________ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users