Я пытаюсь обновить данные в таблице с помощью пользовательского ввода. Тем не менее, я получаю эту ошибку, когда при выполнении функции.
Traceback (most recent call last):
File "E:/Programming Fundamentals/TEST.py", line 396, in <module>
post_start_up() # Starts the post_start_up function
File "E:/Programming Fundamentals/TEST.py", line 384, in post_start_up
menu()
File "E:/Programming Fundamentals/TEST.py", line 146, in menu
menu_opt3() # Runs the menu option 3 function
File "E:/Programming Fundamentals/TEST.py", line 222, in menu_opt3
c.execute(''' UPDATE tblCategory SET Category = ? WHERE CategoryID = ?'''), (cat_inpt, id_inpt)
sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 2, and there are 0 supplied.
Код выполняемой функции:
def menu_opt3():
print("You chose option 3. Update Categories.. \n")
print("CatID, UserID, CategoryName, CategoryBudget \n")
c.execute("SELECT * FROM tblCategory")
for row in c.fetchall():
print(row)
id_inpt = int(input("Please enter the ID of the category you'd like to update"))
option_input = input("Would you like to update the name (A) or the monthly budget (B) of the category?: \n")
if option_input == "A":
cat_inpt = input("Please enter the new name of the category: \n")
c.execute(''' UPDATE tblCategory SET Category = ? WHERE CategoryID = ?'''), (cat_inpt, id_inpt)
conn.commit()
print("Data updated successfully. \n")
menu()
elif option_input == "B":
bdgt_inpt = int(input("Please enter the new monthly budget of the category: \n"))
c.execute(''' UPDATE tblCategory SET CategoryMonthlyBudget = ? WHERE CategoryID = ?'''), (bdgt_inpt, id_inpt)
conn.commit()
print("Data updated successfully. \n")
menu()
else:
print("Invalid user input. \n")
menu()
Любая помощь будет оценена, так как это важно, чтобы я получил это работает, и это, вероятно, только что-то маленькое, что я пропустил!