title: How to see what rows were added with Django connection.cursor.execute()?
body: <p>I have this python code ...</p>
  
  <pre><code>    sql = """
  INSERT INTO app_table(...cols..) 
  SELECT DISTINCT ... cols ... FROM app_temptable e 
  WHERE something = 'Generic' AND NOT EXISTS 
  (SELECT id FROM app_table u WHERE e.somethingelse = u.somethingelse);
      """
      try:
          with connection.cursor() as cursor:
              cursor.execute(sql)
              log.info( '%s rows inserted.' % cursor.rowcount)
              for row in cursor.fetchall():
                  print(row)
      except Exception as ex:
          err = ex
          log.error("sql: %s" % sql)
          raise err
  </code></pre>
  
  <p>... it prints the row count and then throws the exception:</p>
  
  <pre><code>django.db.utils.InterfaceError: not a query
  </code></pre>
  
  <p>I guess because I wasn't doing a select.  But the Django documentation (<a href="https://docs.djangoproject.com/en/2.2/topics/db/sql/" rel="nofollow noreferrer">https://docs.djangoproject.com/en/2.2/topics/db/sql/</a>) says to get the affected rows call 
  <code>cursor.fetchall()</code>.</p>
  
  <p>So how do I get the affected/rows inserted?
  I am using a Oracle database.</p>
  
  <p>It says it here:</p>
  
  <p><a href="https://i.stack.imgur.com/02KWy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/02KWy.png" alt="enter image description here"></a></p>