Get last inserted row ID with Psycopg2 and a Greenplum database

Viewed 4208

How can you get the ID of the last inserted row using psycopg2 on a Greenplum database?

Here are several things I've tried already that don't work.

  • RETURNING isn't supported by Greenplum.
  • psycopg2's cursor.lastrowid always returns 0.
  • SELECT nextval() gives me the next row id, but also increments the counter so the actual inserted row uses a different id.
  • SELECT currval() isn't supported.

Thanks in advance.

4 Answers
Related