'Close this ResultProxy.
Closes the underlying DBAPI cursor corresponding to the execution.
Note that any data cached within this ResultProxy is still available.
For some types of results, this may include buffered rows.
If this ResultProxy was generated from an implicit execution,
the underlying Connection will also be closed (returns the
underlying DBAPI connection to the connection pool.)
This method is called automatically when:
* all result rows are exhausted using the fetchXXX() methods.
* cursor.description is None.'

def close(self, _autoclose_connection=True):

    if (not self.closed):
        self.closed = True
        self.connection._safe_close_cursor(self.cursor)
        if (_autoclose_connection and self.connection.should_close_with_result):
            self.connection.close()
        self.cursor = None
