My python is running a query and returns the output txn_time as shown below.
try:
connection = pymysql.connect(host=db, user=user,
password=pwd,
db=db_name)
with connection.cursor() as cursor:
cursor.execute(**txn_query**.format(a,b,c))
return cursor.fetchall()
except:
txn_query= "SELECT txn_time FROM transactions WHERE CUSTOMERID in (12345) txn_type IN (111) ORDER BY 1 DESC"
Output: (datetime.datetime(2020, 8, 25, 10, 6, 29),)
I need to format it to the time: 2020-08-25 10:06:29 Tried to format is using strftime but couldn't achieve. Can someone help help or guide me to the right pages.