[ACCEPTED]-Returning a value with psycopg2-psycopg2
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()
should work 1 in your scenario.
RETURNING works on Postgresql >= 8.2
More Related questions