【发布时间】:2019-10-06 04:37:17
【问题描述】:
谁能解释如何使用 python 将日期时间插入 SQLite 数据库? 哪个数据类型应该是日期时间,我尝试了很多不同的方法
我的疑惑是基于cs50中的问题集7,我们使用flask作为web框架
history 是数据库的名称
transaction 是字段名称
db.execute("INSERT INTO history (transaction) VALUES(:d)",
d=datetime.datetime.today())
错误消息,我在运行应用程序时收到此消息
builtins.RuntimeError
RuntimeError: near "transaction": syntax error [SQL: "INSERT INTO history (transaction) VALUES('2019-05-19 17:14:25')"] (Background on this error at: http://sqlalche.me/e/e3q8)
【问题讨论】:
标签: python-3.x sqlite datetime sql-insert