def index_exists(cursor, index_name):
    """
    Checks if an index with the given name exists in the database

    :param cursor: database connection cursor
    :param index_name: string
    :return: boolean
    """
    cursor.execute("SELECT COUNT(1) FROM pg_indexes WHERE indexname = %s",
                   [index_name])
    return cursor.fetchone()[0] > 0