I have a datetime object that I want to INSERT in an SQL database TIMESTAMP column.
However, the procedure always fails due to formatting mismatch.
The datetime object:
date = datetime.datetime.strptime('2021-07-21 00:00:00', '%Y-%m-%d %H:%M:%S')
I tried to format it this way:
datetime.datetime.timestamp(date)
But it didn't work out, I think because the timestamp() function returns a float.
Is there a way to properly convert the datetime object to timestamp?
datetime, but I want to convertdatetimetotimestamp.strftime('%Y-%m-%d %H:%M:%S')this has worked for me uploading to timestamp fields in several types of SQL (admittedly, never tried it in mysql)