import logging


def get_ids(cur, id_or_labels):
    """Create a list of IDs from a list of IDs or labels."""
    ids = []
    for id_or_label in id_or_labels:
        cur.execute(f"SELECT term FROM tmp_labels WHERE label = '{id_or_label}'")
        res = cur.fetchone()
        if res:
            ids.append(res[0])
        else:
            # Make sure this exists as an ID
            cur.execute(f"SELECT label FROM tmp_labels WHERE term = '{id_or_label}'")
            res = cur.fetchone()
            if res:
                ids.append(id_or_label)
            else:
                logging.warning(f" '{id_or_label}' does not exist in database")
    return ids