Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
import sqlite3 #imports required module
import time #""
import spoonacular #""
conn = sqlite3.connect('allergy database.db') #connects to database
c = conn.cursor() #assigns to variable, allows to easily manipulate databases shorter
api_key = spoonacular.API("ead370a8f416f971e9572c1f54c84") #registered an account with Spoonacular and got a key. Giving the external function the key as required input and assigning it to value for simplicity's sake
def allergen_reviewer():
"""recipe analysed for common allergies and their allergens"""
recipe = input ("Which of our recipies would you like to examine for allergies?") #user inputs recipe
recipe = api_key.get_analyzed_recipe_instructions(recipe) #external function returns recipe itself
ingredients = information[0]['ingredients'] #ingredients is assigned to contain only the ingredients of the recipe itself
for i in ingredients: #so each ingredient can be analysed individually
query = "SELECT ingredient, allergen from ingredient analysis where ingredient = ?" #searching the database for the ingredient
c.execute(query, [i]) #query above is execueted and ? is assigned to be 'i' ie the ingredient
records = c.fetchall() #information is stored
if records == []: #ie. no data returned, because it isn't there
print("there does not seem to be common / notable allergens in this recipe")
else:
print("NOTE: the following *notable* allergens are contained within this recipe :")
for row in records:
print("this recipe contains " + row[0] + "/n which contains " + row[1]) #where row0 is the first column and row1 is the column containing allergens