def _delete_existing_table(self, table_kind):
        """Delete an existing table in the db"""
        sql = QUERY_ALL_TABLES_TEMPLATE.render()
        self._cur.execute(sql)
        all_tables = self._cur.fetchall()
        if len(all_tables) == 0:
            _LOGGER.info("deleting table: skip empty table")
            return

        target_tables = [
            table[0]
            for table in all_tables
            if table[0].startswith(f"{self._target}_{table_kind}")
        ]
        assert len(target_tables) != 0, f"no {table_kind} table exists"
        # To simplify the logic, we only keep a single table for each kind
        assert (
            len(target_tables) == 1
        ), f"expected only one {table_kind} table but got {target_tables=}"
        _LOGGER.info(f"deleting table {target_tables[0]=}")
        self._cur.execute(f"DROP TABLE {target_tables[0]}")
Delete an existing table in the db
python/aitemplate/backend/profiler_cache.py