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

From Daniele Varrazzo
Subject Re: How to lock a table for update and make other connections to wait on it
Date
Msg-id CA+mi_8Yq0JnMhUfJPOnp8qOegxd3wMa4Sjaxf_j4-2Gtkk1E0g@mail.gmail.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>)
Responses Re: How to lock a table for update and make other connections to wait on it
List psycopg

On Thu, Jul 9, 2015 at 5:31 PM, 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 fetches the max ‘id’ from the table (id is a column in the table which gets incremented on each insert)

 
You can use "INSERT ... RETURNING id" and avoid any concurrency issues.


-- Daniele

psycopg by date:

Previous
From: "Vamsi Krishna Reddy -T (vamsredd - TATA CONSULTANCY SERVICES LIMITED at Cisco)"
Date:
Subject: How to lock a table for update and make other connections to wait on it
Next
From: Christophe Pettus
Date:
Subject: Re: How to lock a table for update and make other connections to wait on it