[sqlalchemy] Re: Lock table, do things to table, unlock table: Best way?

2012-05-30 Thread Jeff
Unique constraints have worked well. Thanks! On May 29, 1:44 pm, Michael Bayer mike...@zzzcomputing.com wrote: yup On May 29, 2012, at 1:01 PM, Jeff wrote: Thanks  Michael, Just to make clear what exactly begin_nested() is contributing: Normal case: session.rollback() goes

[sqlalchemy] Re: Lock table, do things to table, unlock table: Best way?

2012-05-29 Thread Jeff
Thanks Michael, Just to make clear what exactly begin_nested() is contributing: Normal case: session.rollback() goes back to the last session.commit() session.begin_nested() case: session.rollback() goes back to the last session.begin_nested() or session.commit(), whichever occurred last.

[sqlalchemy] Re: Lock table, do things to table, unlock table: Best way?

2012-05-28 Thread Jeff
The unique constraint sounds like a workable solution! I'll implement that with a try/except and report back if that was effective. Thanks! On May 28, 5:43 am, Simon King si...@simonking.org.uk wrote: On Sun, May 27, 2012 at 6:18 PM, Jeff jeffalst...@gmail.com wrote: Thanks, I have indeed

Re: [sqlalchemy] Re: Lock table, do things to table, unlock table: Best way?

2012-05-28 Thread Michael Bayer
An option to add along to the unique constraint, if you expect to get collisions often, is to use a SAVEPOINT so that a process can roll back partially if this particular INSERT fails, then use the row. The Session offers SAVEPOINT via begin_nested(): session.begin_nested() try:

[sqlalchemy] Re: Lock table, do things to table, unlock table: Best way?

2012-05-27 Thread Jeff
Thanks, I have indeed spent a lot of time looking at SELECT FOR UPDATE, but as far as I can tell that locks rows that have been selected. That is not helpful in this use case, in which the issue is rows not existing, and then later existing. Am I misunderstanding? On May 27, 11:48 am, A.M.

[sqlalchemy] Re: Lock table, do things to table, unlock table: Best way?

2012-05-26 Thread Jeff
Hmmm. It also appears that the 4 step solution I gave above doesn't work consistently. Any ideas as to why not? On May 27, 1:07 am, Jeff jeffalst...@gmail.com wrote: I have multiple processes accessing  a table. All of these processes want to read a set of rows from the table, and if the rows