python datetime 写入mysql datetime类型

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python datetime 写入mysql datetime类型相关的知识,希望对你有一定的参考价值。

最近有个python项目需要更新mysql时间,类型是datetime,参考了网上的建议,将时间转为字符串再写入数据库。

def toMysqlDateTime():

    dt=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    return dt

本文出自 “hehe” 博客,请务必保留此出处http://476946.blog.51cto.com/466946/1945225

以上是关于python datetime 写入mysql datetime类型的主要内容,如果未能解决你的问题,请参考以下文章

python shelve模块

向 mysql 数据库中写入datetime 类型数据时 出现全是0的错误解决办法

Python+Selenium进行UI自动化测试项目中,常用的小技巧3:写入excel表(python,xlsxwriter)

Python模块-datetime模块

Python MySQL 错误 1064 插入日期时间字符串

python连接mysql之查询及写入excel