首页 > 解决方案 > 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)

我错过了什么?

非常感谢。

标签: pythonsqlite

解决方案


推荐阅读