title: Get last inserted row ID with Psycopg2 and a Greenplum database
body: <p>How can you get the ID of the last inserted row using psycopg2 on a Greenplum database?</p>
  
  <p>Here are several things I've tried already that don't work.</p>
  
  <ul>
  <li>RETURNING isn't supported by Greenplum.</li>
  <li>psycopg2's cursor.lastrowid always returns 0.</li>
  <li>SELECT nextval() gives me the next row id, but also increments the counter so the actual inserted row uses a different id.</li>
  <li>SELECT currval() isn't supported.</li>
  </ul>
  
  <p>Thanks in advance.</p>