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

Поиск
Список
Период
Сортировка
От Daniele Varrazzo
Тема Re: How to lock a table for update and make other connections to wait on it
Дата
Msg-id CA+mi_8Yq0JnMhUfJPOnp8qOegxd3wMa4Sjaxf_j4-2Gtkk1E0g@mail.gmail.com
обсуждение исходный текст
Ответ на 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>)
Ответы Re: 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>)
Список 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 по дате отправления:

Предыдущее
От: "Vamsi Krishna Reddy -T (vamsredd - TATA CONSULTANCY SERVICES LIMITED at Cisco)"
Дата:
Сообщение: How to lock a table for update and make other connections to wait on it
Следующее
От: Christophe Pettus
Дата:
Сообщение: Re: How to lock a table for update and make other connections to wait on it