def ADD_SIDE():
    name = intermediary.get_name()
    recipe = intermediary.get_recipe()
    dish_type = intermediary.get_type()
    cur.execute('insert or ignore into recipes (name, type, recipe_file) values (?,?,?)', (name, dish_type, recipe))
    rid = get_recipe_id(name)
    INGREDIENTS = intermediary.get_ingredients()
    for ingred in INGREDIENTS.values():
        if ingred != '':
            add_ingredient(ingred)
            id = get_ingredient_id(ingred)
            print(id)
            add_side_ingredient(rid, id)
def EDIT_SIDE(recipe):
    rid = get_recipe_id(recipe)
    INGREDIENTS = intermediary.get_ingredients()
    IIDS = set()
    for ingred in INGREDIENTS.values():
        if ingred != '':
            add_ingredient(ingred)
            IIDS.add(get_ingredient_id(ingred))
    ORIGINAL = set(get_side_ingredients(rid))
    if IIDS != ORIGINAL:
        OLD = ORIGINAL - IIDS
        for old in OLD:
            cur.execute('delete from side_ingredients where recipe_id=%1s and ingredient_id=%2s' % (rid, old))
        IIDS = IIDS - ORIGINAL
        for iid in IIDS:
            add_side_ingredient(rid, iid)
    recipe_file = intermediary.get_recipe()
    if recipe_file != get_recipe_text(rid):
        cur.execute('update recipes set recipe_file="%s" where id=%u' % (recipe_file, rid))
    conn.commit()