def _table_exists(self, table_kind, cache_version):
        """Check if the table of given kind and cache version exists."""
        table_name = f"{self._target}_{table_kind}_{cache_version}"
        sql = CHECK_TABLE_EXISTENCE_TEMPLATE.render(table_name=table_name)
        self._cur.execute(sql)
        tables = self._cur.fetchall()

        if tables:
            _LOGGER.info(
                f"{table_name=} exists in the db",
            )
            return True
        else:
            _LOGGER.info(
                f"{table_name=} does not exist in the db, possible version mismatch!",
            )
            return False
Check if the table of given kind and cache version exists.
python/aitemplate/backend/profiler_cache.py