import sqlite3


def load_history_db(history_db):
    """ Load simulation history from provided db.
    In case no db is given, returns an empty history

    :param history_db:
    :return:
    """
    history = {}
    if history_db is not None:
        conn = sqlite3.connect(history_db)
        cursor = conn.cursor()

        for robot_string, fitness in cursor.execute('SELECT * FROM history'):
            history[robot_string] = (float(fitness),)

        cursor.close()
        conn.close()

    return history