title: SQLAlchemy commit sql execution after iterating through results with fetchall method
body: <p>I'm running into issues with reading results created through OUTPUT statements in SQLAlchemy. I originally had an issue reading the primaryKey of an inserted row, but was able to get it to work using the following code setting autocommit to false:</p>
  <pre><code>sqlString = &quot;&quot;&quot; INSERT INTO workflow.{table}  ({columns})
                  OUTPUT Inserted.{primaryKey}
                  VALUES ({values})&quot;&quot;&quot;.format(table=self.table, columns=columns, primaryKey=self.primaryKey, values=values)
  
      with self.dict_db['engine'].connect().execution_options(autocommit=False) as connection:
        result = connection.execute(sqlString)
        primaryKey = result.fetchone()[0]
        result.cursor.commit()
  </code></pre>
  <p>Now I am writing a delete statement where I want to do something similar, however after iterating through my results, the cursor object is set to None so I can no longer commit. I have tried both using a for loop that iterates over <code>results</code> and <code>results.fetchall()</code> and in both cases I cannot commit because the cursor is None. Here is my code as it stands:</p>
  <pre><code>    sqlString = &quot;&quot;&quot; DELETE FROM workflow.{table} OUTPUT Deleted.{primaryKey} {where} &quot;&quot;&quot;.format(table=self.table, primaryKey=self.primaryKey, where=whereStatement)
  
      with self.dict_db['engine'].connect().execution_options(autocommit=False) as connection:
        result = connection.execute(sqlString)
        # cursor exists
        primaryKeyList = [item[0] for item in result.fetchall()]
        # cursor is now None
        result.cursor.commit()
  </code></pre>
  <p>The fact that this doesn't work is making me rethink both DB executions. Am I doing something drastically wrong here or is there some small syntax I am missing?</p>
  <p>Note: the <code>self.dict_db['engine']</code> is created with sqlalchemy create_engine</p>