I want to delete records older than 7 days automatically, but it doesn't work. Message is showing that older data is deleted, but actually it did not delete the data.
My code is:
try:
db= MySQLdb.connect("localhost","root","","testDB")
cursor=db.cursor()
sql="DELETE FROM CALLRECORD WHERE DATE< DATE_SUB(NOW(), INTERVAL 7 DAY)"
try:
cursor.execute(sql)
db.commit()
print "Deleted Older Data from database"
except:
db.rollback()
print "Cann't delete older data"
db.close()
except:
print "localserver not connected"