On Oct 16, 2013, at 1:38 PM, Iain Duncan <[email protected]> wrote:

> Hi folks, I'm working on a legacy database that has some issues with PK 
> generation. The long and short of it is that for now, I need to generate an 
> PK by locking a table, because that's what they've been doing. I'm using the 
> orm, and basically want to be able to use a session briefly with the table 
> locked. ( to find the highest PK in there and increment. I know....hope we 
> can fix that later ). I'm wondering what the best way to do this is.
> 
> I could use a connection to lock the table with raw sql, but then can I use a 
> session for the query?

sure.  session.execute("lock the table...") then keep using that Session in the 
same transaction.   once that Session has commit() called the transaction is 
over and the lock will be cleared.




Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to