I'm looking to insert the ID of the current user into a table called Orders in my SQLite database
results is a variable that represents the current user that is logged in and looks like this:
existingAccount = input("Do you already have an account? (y/n)")
if existingAccount == "y":
username = input("Please enter your username: ")
password = input("Please enter your password:")
find_user = "SELECT * FROM Users WHERE Username = ? AND Password = ?"
c.execute(find_user, [username, password])
results = c.fetchall()
later on this variable is checked to see if the user is an admin to allow them to perform certain functions using results[0][3], the third column being the permission level.
My original idea was to use results[0][0] to fetch the ID and to add it to the table:
shopping = True
while shopping:
itemToAdd = input("Please enter the ID of the item to add to the basket: ")
basket.append(itemToAdd)
print(basket)
continueShop = input("Continue shopping?(y/n): ")
if continueShop == "n":
conn.execute("INSERT INTO Orders (UserID) VALUES = (?)", (results[0][0]))
conn.commit()
Printing results[0][0] gives me the ID as I want however I am not able to insert it into the table and am given this when debugging.