import sqlite3 conn = sqlite3.connect("bandj.db") print("Hi, it's Danny!") cur = conn.cursor() # EVIL EVIL EVIL vvvv #cur.execute(f"select name from recipe where baseflavor='{fave_flave}'") #cur.execute("select name from recipe where baseflavor='{}'".format(fave_flave)) #cur.execute("select name from recipe where baseflavor='" + fave_flave + "'") # EVIL EVIL EVIL ^^^^ fave_flave = input("What's yer fave flave? (or done) ") while fave_flave != "done": print(f"Hey, I love {fave_flave} too!") # GOOD GOOD GOOD vvvv cur.execute("select name from recipe where baseflavor=?", (fave_flave,) ) # GOOD GOOD GOOD ^^^^ results = cur.fetchall() i = 1 for item in results: print(f"{i}) {item[0]}") i += 1 print(f"Which of our scrumptious {fave_flave}-based recipes would you like?") choice = int(input("> ")) order_choice = results[choice-1][0] cartons_requested = int(input( f"How many cartons of {order_choice} do you want? ")) cur.execute("update recipe set co=co+? where name=?", (cartons_requested, order_choice)) conn.commit() fave_flave = input("What's another great flave? (or done) ")