I have a MySQL table in which every row contains a 'Date' value. I want to delete all the rows where the date is unequal to the current date. I tried using the following lines to do so:
date = time.strftime('%Y-%m-%d')
mycursor.execute("DELETE FROM " + League + " WHERE Date != " + "'" + date + "'")
It runs fine, but it doesn't actually delete any rows, even though I am sure there are rows with different dates. How can I delete these rows?
<>if I am not wrong, also you need tocommitthe transaction, also don't use string concatenation, it is prone to SQL injection