I'm trying to perfect this SQL delete statement for Python, where currently I want to just delete this row so I can get the formatting right. However the row just isn't being deleted. Could I have some friendly feedback on why it isn't being removed.
I call my function like this:-
self.DeleteOrderFromBook("Admin", "0", "100", "50", "2021-02-26 20:29:39.297658")
def DeleteOrderFromBook(self,Name,BuyOrSell,Amount,Price,Time):
try:
conn = sqlite3.connect("Books.db")
c = conn.cursor()
fml = "DELETE FROM TraidingBook WHERE Username='{0}' AND BuyOrSell='{1}' AND Amount='{2}' AND Price='{3}' AND TimeStamp='{4}';".format(Name,BuyOrSell,Amount,Price,Time)
print(fml)
c.execute(fml)
conn.commit()
conn.close()
return True
except:
return False
That is the python function for making the string.
DELETE FROM TraidingBook
WHERE Username='Admin'
AND BuyOrSell='0'
AND Amount='100'
AND Price='50'
AND TimeStamp='2021-02-26 20:29:39.297658';
However this line in the Database still exists -
('Admin', 0, 100, 50, '2021-02-26 20:29:39.297658')
Could someone please let me know what I'm doing wrong. Thanks.