Wer weiß, wie eine Abfrage in einem Wert in Python SQLiteeine Abfrage in SQLite-Wert verwenden - Python
Die eroor ich bin immer ist auszuführen: sqlite3.InterfaceError: Fehler 1-Bindungsparameter - wahrscheinlich nicht unterstützten Typs.
mein Code ist hier:
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")
bearbeiten Frage und Formatcode. – furas
@furas was meinst du –
'result' kann Iterator' sein. Sie müssen eine einzelne Zeile vom Interator und später ein einzelnes Element aus der Zeile abrufen. – furas