【发布时间】:2019-10-06 20:56:54
【问题描述】:
我正在尝试创建一个系统(使用不和谐机器人,但这与此无关),其中列出了用户的违规行为,例如发生的时间、地点、原因等,我想要一个“日期”数据类型记录它发生的时间戳。
我尝试将 DATE 数据类型设置为“时间戳”(以及“日期时间”,但发生同样的错误)
conn1 = apsw.Connection('./dbs/warns.db')
warns = conn1.cursor()
warns.execute(
"""
CREATE TABLE IF NOT EXISTS warns
(id INTEGER PRIMARY KEY AUTOINCREMENT,
date timestamp,
server string,
user string,
author string,
reason string)
"""
)
def add_warn(guild: str, user: str, author: str, reason):
now = datetime.datetime.utcnow()
with conn1:
warns.execute("INSERT INTO warns (date, server, user, author, reason) VALUES (?, ?, ?, ?, ?)", (now, guild, user, author, reason))
我最终得到一个TypeError: Bad binding argument type supplied - argument #1: type datetime.datetime 错误
【问题讨论】:
-
您使用的是哪个数据库:mysql、oracle、sql-server,...?请在您的问题中添加相关标签。
标签: python sql date datetime apsw