'Disable IDENTITY_INSERT if enabled.'

def post_exec(self):

    conn = self.root_connection
    if self._select_lastrowid:
        if self.dialect.use_scope_identity:
            conn._cursor_execute(self.cursor, 'SELECT    scope_identity()    AS    lastrowid', (), self)
        else:
            conn._cursor_execute(self.cursor, 'SELECT    @@identity    AS    lastrowid', (), self)
        row = self.cursor.fetchall()[0]
        self._lastrowid = int(row[0])
    if ((self.isinsert or self.isupdate or self.isdelete) and self.compiled.returning):
        self._result_proxy = engine.FullyBufferedResultProxy(self)
    if self._enable_identity_insert:
        conn._cursor_execute(self.cursor, ('SET    IDENTITY_INSERT    %s    OFF' % self.dialect.identifier_preparer.format_table(self.compiled.statement.table)), (), self)
