python - Python:TypeError:需要一个整数(获取类型 sqlite3.Cursor)
问题描述
我正在开发一个 Python、Flask 和 Sqlite3 的项目。
保存了Sqlite3数据库:
id time
0 1622128251
我想在python中获取最新的时间戳数据:</p>
import sqlite3
con = sqlite3.connect('daily_projections.db')
cur = con.cursor()
# select the newest time
sql = "select * from execute_time order by id desc limit 0, 1"
execute_time = cur.execute(sql)
# change to the UTC time
execute_time = datetime.utcfromtimestamp(execute_time)
cur.close()
con.close()
但我得到一个错误:
TypeError: an integer is required (got type sqlite3.Cursor)
我错过了什么?
非常感谢。
解决方案
推荐阅读
- javascript - 模块和工厂函数有什么区别?
- jenkins - 即使没有更改,Jenkins 作业 dsl 也会在每次运行时对 multibranchPipelineJob 作业进行分支扫描
- java - 如何在我的 ArrayList 中显示 5 个对象?
- java - 在数据库中添加 Enum 的键和描述
- c++ - 错误 C1189 #error: C++ 标准库禁止宏化关键字“内联”
- python - 像目录一样写入 Google Cloud 存储桶?
- javascript - 获取文件:///eel.js net::ERR_FILE_NOT_FOUND。但是我通过cmd下载了鳗鱼,做了和作者一样的事情
- reactjs - React Hook 显示表单上选中的所有框
- python - 如何提高单行选择(即查找)的 PyODBC 性能?
- r - 在 R 中是否有可能通过添加两个数据框我们得到结果,即使相同类型的其他值不存在?