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()