I have code that selects the max timestamp from a MySQL db as follows:
cursor = connection.cursor()
cursor.execute("SELECT max(played_at) FROM
testDB.Log;")
max_date = cursor.fetchall()
it returns a datetime.datetime object like this:
((datetime.datetime(2019, 6, 4, 11, 44, 5),),)
I need it to return a timestamp in the format %Y-%m-%d %H:%M:%S
I have tried using strptime(), datetime(), and strftime() but each time I get the error "tuple has no object (insert one of the three)"
How can I get the format i want?
strftimeis just fine, the only problem is that you need to apply it to an index of the tuple, not the whole tuple itself.max_date[0][0]gets you at the datetime itself