【发布时间】:2014-12-22 23:20:42
【问题描述】:
我有以下 python 代码:
now = time.strftime('%Y-%m-%d %H:%M:%S')
#now = datetime.datetime.now()
query = """INSERT INTO bandwidth_by_second (current_time, down, up) VALUES (%s, %s, %s)"""
data = (now, 1.0, 2.0)
cursor.execute(query, data)
我的这个表的架构是:
- current_time - 数据时间
- 向下 - 双
- 向上 - 双倍
运行时出现以下错误:
_mysql_exceptions.ProgrammingError: (1064, "您的 SQL 语法有错误;请查看与您的 MySQL 服务器对应的手册 在 'current_time, down, up) 附近使用正确语法的版本 VALUES ('2014-10-27 18:29:32', 1, 1)' at line 1")
我原以为我的日期时间格式错误,但this post 建议不正确。
这到底是怎么回事?
【问题讨论】: