我不斷收到錯誤在Python錯誤「錯誤號碼提供給綁定」:什麼呢使用SQLite
Incorrect number of bindings supplied
CCAN誰能告訴我這是什麼意思?
在那裏我得到的錯誤代碼是:
import sqlite3
statement=''
name=''
def update_data(values):
with sqlite3.connect("mrsimms.db")as db:
cursor = db.cursor()
sql = statement
cursor.execute(sql,values)
db.commit()
def update_product_type():
statement= "Update Stock set Type=? where Name=?"
Type=input("Please enter the updated type: ")
data=(Type)
update_data(data)
print()
again=input('Would you like to do anything else?(y/n) ')
if again =='y':
menu()
else:
print()
def update_product_retail_price():
statement= "Update Stock set RetailPrice=? where Name=?"
RetailPrice=input("Please enter the updated retail price: ")
data=(RetailPrice)
update_data(data)
print()
again=input('Would you like to do anything else?(y/n) ')
if again =='y':
menu()
else:
print()
def update_product_number_in_stock():
statement= "Update Stock set NumberInStock=? where Name=?"
NumberInStock=input("Please enter the updated number in stock: ")
data=(NumberInStock)
update_data(data)
print()
again=input('Would you like to do anything else?(y/n) ')
if again =='y':
menu()
else:
print()
def menu():
Name = input("Please enter the name of the product you wish to update: ")
print()
print('1. Update the product type')
print('2. Update the product retail price')
print('3. Update number in stock ')
print('9. Quit ')
print()
choice=int(input('What would you like to do? '))
if choice == 1:
update_product_type()
elif choice == 2:
update_product_retail_price()
elif choice == 3:
update_product_number_in_stock()
elif choice == 9:
print()
menu()
我試圖編輯我的數據庫中的記錄,我不能看到我做了什麼錯。任何幫助將是可愛的,我是新的Python使用數據庫。
該代碼甚至不起作用,因爲您沒有將'statement'傳遞給'update_data'。 –