def query_cache(
    db_conn_cur: sqlite3.Cursor,
    table: str,
    op_type: str,
    op_keys: str,
    query_template: str,
    algo: str = None,
    device: str = None,
    entry_id: int = None,
    suppress_print: bool = False,
    exec_key: str = None,
    dtype_acc: str = None,
) -> List[Tuple[int, str, str, str, str, str]]:
    """query the database for the given op_type and op_keys in the table and
       print out the entries if the query succeeds.

    Parameters
    ----------
    db_conn_cur: sqlite3.Cursor
        sqlite3 connection Cursor object
    table: str
        the table to be queried
    op_type: str
        op type in the query, e.g. gemm_rcr_bias
    op_keys: str
        op keys used to construct exec_hash_sh1 in the query, e.g. 2x3x4 for
        gemm-family op type
    query_template: str
        jinja template to be rendered to create the query
    device: str optional
        specify the device field in the query if it's not None. Default value
        is None, which means we will query all device kinds.
    algo: str optional
        specify the also field in the query if it's not None. Default value
        is None.
    entry_id: int optional
        specify the id field in the query if it's not None
    suppress_print: bool optional
        do not print returned queries if it's True
    exec_key: str optional
        we will use this exec_key for query if it's not None
    dtype_acc: str optional
        we will use this dtype_acc for query if it's not None

    Returns
    -------
    List[Tuple[int, str, str, str, str, str]]
        returns a list of valid entries
    """
    exec_entry_sha1 = None
    if op_keys is not None and exec_key is None:
        if op_type.startswith("gemm"):
            exec_key = make_gemm_exec_key(op_keys)
        elif op_type.startswith("bmm"):
            exec_key = make_bmm_exec_key(op_keys)
        elif op_type.startswith("group_gemm"):
            exec_key = make_group_gemm_exec_key(op_keys)
        else:
            raise RuntimeError("invalid op_type: " + op_type)

    if exec_key is not None:
        if not suppress_print:
            _LOGGER.info("exec_key: '%s'", exec_key)
        exec_entry_sha1 = hashlib.sha1(exec_key.encode("utf-8")).hexdigest()
        if not suppress_print:
            _LOGGER.info("exec_sha1: '%s'", exec_entry_sha1)

    query_args = {
        "table": table,
        "op_type": op_type,
    }
    query_args["has_exec_entry_sha1"] = False
    if exec_entry_sha1 is not None:
        query_args["exec_entry_sha1"] = exec_entry_sha1
        query_args["has_exec_entry_sha1"] = True

    query_args["has_device"] = False
    if device is not None:
        query_args["device"] = device
        query_args["has_device"] = True

    query_args["has_entry_id"] = False
    if entry_id is not None:
        query_args["id"] = entry_id
        query_args["has_entry_id"] = True

    query_args["has_dtype_acc"] = False
    if dtype_acc is not None:
        query_args["dtype_acc"] = dtype_acc
        query_args["has_dtype_acc"] = True

    query_args["has_algo"] = False
    if algo is not None:
        query_args["algo"] = algo
        query_args["has_algo"] = True

    query = query_template.render(**query_args)
    if not suppress_print:
        print("query:{}".format(query))

    db_conn_cur.execute(query)
    entries = db_conn_cur.fetchall()
    if not suppress_print:
        _LOGGER.info("entries: id, op_type, algo, device, exec_entry")
    for entry in entries:
        if not suppress_print:
            print("entry: {}".format(entry))
    return entries
query the database for the given op_type and op_keys in the table and
print out the entries if the query succeeds.

Parameters
----------
db_conn_cur: sqlite3.Cursor
sqlite3 connection Cursor object
table: str
the table to be queried
op_type: str
op type in the query, e.g. gemm_rcr_bias
op_keys: str
op keys used to construct exec_hash_sh1 in the query, e.g. 2x3x4 for
gemm-family op type
query_template: str
jinja template to be rendered to create the query
device: str optional
specify the device field in the query if it's not None. Default value
is None, which means we will query all device kinds.
algo: str optional
specify the also field in the query if it's not None. Default value
is None.
entry_id: int optional
specify the id field in the query if it's not None
suppress_print: bool optional
do not print returned queries if it's True
exec_key: str optional
we will use this exec_key for query if it's not None
dtype_acc: str optional
we will use this dtype_acc for query if it's not None

Returns
-------
List[Tuple[int, str, str, str, str, str]]
returns a list of valid entries
tests/ci_profile_cache/update_cache.py