title: psycopg2: How to know when cur.rowcount does not mean number of rows?
body: <p>I'm looking for a way to programatically determine the difference between <code>cur.rowcount</code> describing the number of rows available to fetch versus the number of rows affected.</p>
  
  <p>For example:</p>
  
  <pre><code>&gt;&gt;&gt; cur.execute('CREATE TABLE test (gid serial, val numeric);')
  &gt;&gt;&gt; cur.execute('INSERT INTO test (val) values (1), (2), (3);')
  &gt;&gt;&gt; cur.execute('SELECT * FROM test;'); cur.rowcount
  3
  &gt;&gt;&gt; cur.execute('UPDATE test SET val = 1;'); cur.rowcount
  3
  &gt;&gt;&gt; cur.fetchall()
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  psycopg2.ProgrammingError: no results to fetch
  
  &gt;&gt;&gt; cur.execute('DELETE FROM test;'); cur.rowcount
  3
  
  &gt;&gt;&gt; cur.execute('DROP TABLE test;')
  &gt;&gt;&gt; cur.rowcount
  -1
  </code></pre>
  
  <p>Using Python 2.7 and psycopg2 2.6.2.</p>