Inserting a Python datetime.datetime object into MySQL

后端 未结 7 1254
Happy的楠姐
Happy的楠姐 2020-11-27 11:26

I have a date column in a MySQL table. I want to insert a datetime.datetime() object into this column. What should I be using in the execute statement?

7条回答
  •  借酒劲吻你
    2020-11-27 11:37

    For a time field, use:

    import time    
    time.strftime('%Y-%m-%d %H:%M:%S')
    

    I think strftime also applies to datetime.

提交回复
热议问题