def handles(cursor):
    """Returns a dict of handles that form (ROWID, id) pairs."""
    sql_handles = cursor.execute("SELECT ROWID, id FROM handle").fetchall()
    all_handles = dict()

    for handle in sql_handles:
        rowid, contact_id = handle
        all_handles[rowid] = contact_id

    return all_handles