有誰知道如何在python sqlite的執行裏面的值的查詢使用SQLite中值的查詢 - 蟒蛇
我收到eroor是: sqlite3.InterfaceError:錯誤綁定參數1 - 可能不支持的類型。
我的代碼是在這裏:
Name = input("Enter the name of the product you want to purchase: >>")
item = Name
qty = input("Enter the Quantity of the product you want to purchase: >>")
today = date.today()
cursor = db.cursor()
cursor.execute("SELECT CatID from Products where Name=?",(Name,))
result = cursor.fetchall()
confirm = input("are you sure you want tot buy this product (y/n): >>")
if confirm == "y":
### In this query where it says result i want to execute the data from the result query
cursor.execute("INSERT INTO OrderHistory(Username,Category,Date,Qty,ItemHistory) Values(?,?,?,?,?)",(Username,result,today,qty,Name))
db.commit()
print("Product purchased. Thankyou for your order")
cursor.execute("UPDATE Products SET Qty = (? -1) where Name = ?",(qty,item,))
else:
print("The program will now terminate")
編輯問題,格式代碼。 – furas
@furas你是什麼意思 –
'結果'可以是迭代器'。您必須從interator獲取單個行,然後從行獲取單個元素。 – furas