它沒有顯示錯誤并且能夠運行,但是 SQLite 表中的資料沒有更新。然而,與此作業類似的其他更新功能
def seller_edit():
while True:
sellername = str(input("Enter your username: "))
with sqlite3.connect(r"C:\Users\User\Desktop\HFSystem\Assginment\HFuserinfo.db") as connect:
cursor = connect.cursor()
check = "SELECT * FROM sellerinfo WHERE Username = ?"
cursor.execute(check,[sellername])
results = cursor.fetchall()
if results:
Phone = int(input("Enter New Phone No.: "))
Email = str(input("Enter New Email: "))
Address = str(input("Enter New Address: "))
updateseller ="""UPDATE sellerinfo SET Phone = ?, Email=?,Address=? WHERE Username=?"""
cursor.execute(updateseller,[sellername,Phone,Email,Address])
connect.commit()
print("Seller Info Edited!")
connect.close()
seller_info_menu()
break
else:
print("ProductID does not recognised")
option = input("Do you want to try again (y/n): ")
if option.lower() == "n":
seller_info_menu()
break
uj5u.com熱心網友回復:
的第二個引數的元組內的引數cursor.execute()順序必須與起搏器的順序相同?:
cursor.execute(updateseller, (Phone, Email, Address, sellername))
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/447112.html
