5
我想知道SQLAlchemy是否在查询视图时遇到问题。如果我在服务器上用正常的SQL查询视图,如:查询SQLAlchemy中的视图
SELECT * FROM ViewMyTable WHERE index1 = '608_56_56';
我得到一大堆记录。但是对于SQLAlchemy,我只获得第一个。但在计数是正确的数字。我不知道为什么。
这是我的SQLAlchemy代码。
myQuery = Session.query(ViewMyTable)
erg = myQuery.filter(ViewMyTable.index1 == index1.strip())
# Contains the correct number of all entries I found with that query.
totalCount = erg.count()
# Contains only the first entry I found with my query.
ergListe = erg.all()