Re: How to lock a table for update and make other connections to wait on it - Mailing list psycopg

From Christophe Pettus
Subject Re: How to lock a table for update and make other connections to wait on it
Date
Msg-id BE307F8C-E958-4DFF-9695-BB73D3573F47@thebuild.com
Whole thread Raw
In response to How to lock a table for update and make other connections to wait on it  ("Vamsi Krishna Reddy -T (vamsredd - TATA CONSULTANCY SERVICES LIMITED at Cisco)" <vamsredd@cisco.com>)
List psycopg
On Jul 9, 2015, at 9:31 AM, Vamsi Krishna Reddy -T (vamsredd - TATA CONSULTANCY SERVICES LIMITED at Cisco)
<vamsredd@cisco.com>wrote: 

> 1.       Insert a row to a table , using cursor.execute()
> 2.       To fetch the row id of the above inserted data, we are using cursor.execute() to execute a sql command which
fetchesthe max ‘id’ from the table (id is a column in the table which gets incremented on each insert) 

Don't do it that way.  Use the RETURNING clause on INSERT to get the inserted value.
--
-- Christophe Pettus
   xof@thebuild.com



psycopg by date:

Previous
From: Daniele Varrazzo
Date:
Subject: Re: How to lock a table for update and make other connections to wait on it
Next
From: "Karsten Hilbert"
Date:
Subject: Re: How to lock a table for update and make other connections to wait on it