def ADD_MAIN(): ''' Adds a main dish to the database''' name = intermediary.get_name() meat = intermediary.get_meat() VEGGIES = intermediary.get_veggies() starch = intermediary.get_starch() recipe = intermediary.get_recipe() #dish_type = intermediary.get_type() dish_type = 'main' # Put the name of the recipe and the file into the database cur.execute('insert or ignore into recipes (name, type, recipe_file) values (?,?,?)', (name, dish_type, recipe)) rid = get_recipe_id(name) # Try to put the meats and vegetables into the database in case they are not already there for veggie in VEGGIES.values(): if veggie != '': add_veggie(veggie) id = get_veggie_id(veggie) add_recipe_veggie(rid, id) cur.execute('insert or ignore into meats (name) values ("%s")' % meat) mid = get_meat_id(meat) sid = get_starch_id(starch) # Put the meat, vegetable, and starch relationships into the database add_recipe_meat(rid, mid) add_recipe_starch(rid, sid) conn.commit()
def ADD(): name = intermediary.get_name() meat = intermediary.get_meat() veggies = intermediary.get_veggies() # veggies = list(map(str.lower, veggies)) starch = intermediary.get_starch() recipe_string = intermediary.get_recipe() cur.execute("insert into recipes values (?,?,?,?,?,?,?,?)", (name, meat, veggies[0], veggies[1], veggies[2], veggies[3], starch, recipe_string)) conn.commit()
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 get_name(): name = intermediary.get_name()