def process_insert_get_id(self, query, sql, values, sequence=None):
        if not query.get_connection().transaction_level():
            with query.get_connection().transaction():
                query.get_connection().insert(sql, values)

                cursor = query.get_connection().get_cursor()
                if hasattr(cursor, 'lastrowid'):
                    id = cursor.lastrowid
                else:
                    id = query.get_connection().statement('SELECT LAST_INSERT_ID()')
        else:
            query.get_connection().insert(sql, values)

            cursor = query.get_connection().get_cursor()
            if hasattr(cursor, 'lastrowid'):
                id = cursor.lastrowid
            else:
                id = query.get_connection().statement('SELECT LAST_INSERT_ID()')

        if isinstance(id, int):
            return id

        if str(id).isdigit():
            return int(id)

        return id
Process an "insert get ID" query.
dataset/ETHPy150Open sdispater/orator/orator/query/processors/mysql_processor.py/MySQLQueryProcessor.process_insert_get_id