Just to give a bit of background, this is a stock system that calls and retrieves data from a database, everything works except I cant get it to insert values into the database. the code is below and the comments annotate what does and doesn't work, there is a lot more to the code however this works.
try:
cursor.execute("SELECT * FROM LastOrderNum WHERE ID=0")
data=cursor.fetchone()
ordernumber=data[1] + 1
print (ordernumber)# this is ok - it does update the database number
try:
cursor.execute ("UPDATE LastOrderNum SET PurchaseOrder =? WHERE ID=?",(ordernumber, 0)) # this works
#cursor.execute("UPDATE LastOrderNum SET PurchaseOrder = ordernumber WHERE ID = 0")
connect.commit()
print("Got past updating order number")
print(ordernumber, productId, supplierId, OrderQty) # this works it prints the 4 values
cursor.execute("INSERT INTO Order VALUES (?,?,?,?)",(ordernumber,productId,supplierId,OrderQty)) # this will not put them into the database
connect.commit()
print("correct")
content=""
content=content+"\n"+str(row3[num][1]+" "+str(row3[num][2]))
if supplier != supplierId and supplier != None:
content=str("Hello "+str(row3[num][5])+" "+str(row3[num][6])+",\nI am placing an order for these items,\n\n"+content+"\n\nThank you,\nJohn.")
except:
print ("Problem wrting the order details")
except:
print("Problem picking up the last used order number")
the code breaks at the cursor.execute("INSERT INTO ......line) Everything else works and the connection is correct however at this line it just spits it back to the "problem writing order details" exception.
Please help!!!