# Our Ben & Jerry's console-based store! import sqlite3 conn = sqlite3.connect("/home/stephen/teaching/350/bj.db") print("Welcome to Ben & Jerry's") print("What's your favorite flavor?") cursor = conn.execute("select name from flavor") flavorNames = cursor.fetchall() for i in range(len(flavorNames)): print(f"{i+1}) {flavorNames[i][0]}") choice = int(input("> ")) favoriteFlavor = flavorNames[choice-1][0] print(f"Check out these {favoriteFlavor}-based recipes!") cursor = conn.execute( "select name from recipe where flavorName=?", (favoriteFlavor,) ) recipes = cursor.fetchall() for i in range(len(recipes)): print(f"{i+1}) {recipes[i][0]}") choice = int(input("Which one do you want to buy? ")) chosenRecipe = recipes[choice-1][0] numCartons = int(input("Great! How many cartons? ")) conn.execute( "update recipe set cartonsOrdered=cartonsOrdered+? where name=?", (numCartons, chosenRecipe) ) conn.commit() conn.close()