gpt4 book ai didi

python - 在sqlite3中存储python日期

转载 作者:行者123 更新时间:2023-12-01 06:09:25 25 4
gpt4 key购买 nike

有没有办法在 sqlite3 中存储 python 日期或 pyqt4 日期(QDate)?我不想使用 sqlite 的日期类型,因为我需要找到我要存储的日期之间的差异。这就是我正在尝试的:

    record = QtCore.QDate.currentDate()
latest = self.calendar.selectedDate()

db = sql.connect(":memory:")
cur = self.db.cursor()
cur.execute("CREATE TABLE invoices(record, latest)")
cur.execute("INSERT INTO invoices VALUES (?, ?)", (record, latest))
db.commit()

这就是错误:sqlite3.InterfaceError:绑定(bind)参数 0 时出错 - 可能是不受支持的类型。提前致谢。

最佳答案

没有。首先将其转换为时间戳。

关于python - 在sqlite3中存储python日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6623125/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com