不清楚为什么flask_sqlalchemy没有提供查询特定行数的方法,好像可以在db.Column
中设置index,但是我不清楚如何使用。
故只好使用循环遍历的方法:
#index是想要查询的行数
# todo.query.all()会返回一个对象列表
ls = todo.query.all()
for i in range(len(ls)):
if i == index:
theEvent = ls[i]
不清楚为什么flask_sqlalchemy没有提供查询特定行数的方法,好像可以在db.Column
中设置index,但是我不清楚如何使用。
故只好使用循环遍历的方法:
#index是想要查询的行数
# todo.query.all()会返回一个对象列表
ls = todo.query.all()
for i in range(len(ls)):
if i == index:
theEvent = ls[i]
本文标题:利用flask_sqlalchemy获取特定的行
本文链接:https://www.haomeiwen.com/subject/gxvmdftx.html
网友评论