獲得COUNT我:從SQLAlchemy的
res = db.engine.execute('select count(id) from sometable')
返回的對象是sqlalchemy.engine.result.ResultProxy
。
如何從res
獲得計數值?
RES不被索引訪問,但我已經想通了這一點爲:
count=None
for i in res:
count = res[0]
break
必須有正確的更簡單的方法?它是什麼?我還沒有發現它。 注意:db是一個postgres
db。