为什么我的date元素在MySQL中(终端)以以下格式显示:datetime.date(2018,6,30)?

时间:2018-09-03 13:45:48

标签: python mysql tornado

我使用python将日期插入MySQL。在插入日期之前,我将日期格式更改为:

start_datetime_object = datetime.datetime.strptime(str(stDate), '%Y-%m-%d')
end_datetime_object = datetime.datetime.strptime(str(enDate), '%Y-%m-%d')

d_stDate= start_datetime_object.strftime('%Y-%m-%d')

d_enDate= end_datetime_object.strftime('%Y-%m-%d')

当我使用logging.debug("DATES---->" + d_enDate +'-- '+ d_stDate)时 我得到的结果应为%Y-%m-%d格式。

此刻,我坚持使用datetime.date(2018, 6, 30)

编辑:

我的查询是:

cursor1.execute("INSERT INTO "+MYSQL_DB+".events ( `name`, `type`, `startDate`,`endDate`, `location` ) VALUES (%s,%s,%s,%s,%s)",[ str(name), str(types), str(d_stDate),str(d_enDate),str(location)])

0 个答案:

没有答案