import sqlite3 conn = sqlite3.connect("/home/stephen/bandj.db") print("Hi user! I'm Ned.") fave_flave = input("What's yer fave flavor? ") while fave_flave != "done": cur = conn.cursor() # BAD BAD BAD vvv #cur.execute(f"select name from recipe where baseflavor='{fave_flave}'") #cur.execute("select name from recipe where baseflavor='{}'"); #cur.execute("select name from recipe where baseflavor='" + fave_flave + "'"); # BAD BAD BAD ^^^ # GOOD cur.execute("select name from recipe where baseflavor=?", (fave_flave,)) results = cur.fetchall() if len(results) == 0: fave_flave = input(f"Sorry, never heard of {fave_flave}! Enter another:") else: print("What recipe would you like?") for i in range(len(results)): print(f"{i+1}) {results[i][0]}") theirInput = int(input("> ")) thatRecipe = results[theirInput-1][0] print(f"Yay! I like {thatRecipe} too!") user_cartons = int(input( f"How many cartons of {thatRecipe} would you like? ")) cur.execute("update recipe set co=co+? where name=?", (user_cartons, thatRecipe)) conn.commit() fave_flave = input("What's another great flavor? ") print("Ned says bye!") conn.close()