This question has been asked and answered before, but I am getting a syntax error with prior answers. Perhaps I am missing something?
query = "DELETE FROM currentvoltage WHERE timestamp < UNIX_TIMESTAMP(DATE_SUB(NOW() - INTERVAL 1 DAY))"
cursor.execute(query)
currentvoltage
is table
timestamp
is row with timestamp in yyyy-mm-dd hh:mm:ss:ffff
Getting
42601 syntax error "at or near" the "1" for 1 Day
EDIT:
After everyone's assistance, the following was used.
query = "DELETE FROM {} WHERE timestamp < NOW() - INTERVAL '{} DAY'".format(tableName, truncate)
cursor.execute(query)
note: I am pulling the table name and the interval from global variables