From: | "Vamsi Krishna Reddy -T (vamsredd - TATA CONSULTANCY SERVICES LIMITED at Cisco)" <vamsredd(at)cisco(dot)com> |
---|---|
To: | "daniele(dot)varrazzo(at)gmail(dot)com" <daniele(dot)varrazzo(at)gmail(dot)com> |
Cc: | "psycopg(at)postgresql(dot)org" <psycopg(at)postgresql(dot)org>, "Virag Jain (virajain)" <virajain(at)cisco(dot)com> |
Subject: | Re: How to lock a table for update and make other connections to wait on it |
Date: | 2015-07-13 14:06:41 |
Message-ID: | F9E9BF1AB618014BAB5BFAF67628966001A354AD@xmb-rcd-x11.cisco.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | psycopg |
Thank you.
Regards
Vamsi
http://www.cisco.com/web/europe/images/email/signature/logo05.jpg
Vamsi Krishna Reddy
Engineer - Test/QA
vamsredd(at)cisco(dot)com
Phone: +1 978 936 3645
Cisco Systems Limited
300 Beaver Brook Road
BOXBOROUGH
MASSACHUSETTS
01719
US
<http://www.cisco.com> Cisco.com
Think before you print.Think before you print.
This email may contain confidential and privileged material for the sole use of the intended recipient. Any review, use, distribution or disclosure by others is strictly prohibited. If you are not the intended recipient (or authorized to receive for the recipient), please contact the sender by reply email and delete all copies of this message.
For corporate legal information go to:
<http://www.cisco.com/web/about/doing_business/legal/cri/index.html> http://www.cisco.com/web/about/doing_business/legal/cri/index.html
From: Daniele Varrazzo [mailto:daniele(dot)varrazzo(at)gmail(dot)com]
Sent: Thursday, July 09, 2015 1:25 PM
To: Vamsi Krishna Reddy -T (vamsredd - TATA CONSULTANCY SERVICES LIMITED at Cisco)
Cc: psycopg(at)postgresql(dot)org; Virag Jain (virajain)
Subject: Re: [psycopg] How to lock a table for update and make other connections to wait on it
On Thu, Jul 9, 2015 at 5:31 PM, Vamsi Krishna Reddy -T (vamsredd - TATA CONSULTANCY SERVICES LIMITED at Cisco) <vamsredd(at)cisco(dot)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.
http://www.postgresql.org/docs/9.3/static/sql-insert.html
-- Daniele
From | Date | Subject | |
---|---|---|---|
Next Message | Jonathan Rogers | 2015-07-31 14:57:37 | ISQLQuote vs. str subclass |
Previous Message | Karsten Hilbert | 2015-07-09 22:20:41 | Re: How to lock a table for update and make other connections to wait on it |