[ACCEPTED]-Returning a value with psycopg2-psycopg2
Accepted answer
Sure it will, it'll know the ID as soon 4 as the command finishes, that's how RETURNING 3 is implemented. You need to actually fetch 2 it though, so something like:
cursor.execute("INSERT INTO .... RETURNING id")
id_of_new_row = cursor.fetchone()[0]
should work 1 in your scenario.
RETURNING works on Postgresql >= 8.2
0
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.