1. 单纯的使用 count 统计一个表
参考:https://stackoverflow.com/questions/12941416/how-to-count-rows-with-select-count-with-sqlalchemy
count = db.session.query(func.count("*")).select_from(Tags).scalar()
必须使用 select_from()
来指定统计哪个表,不然 SQLAlchemy
不知道针对哪个表进行操作。除非后面使用了 filter
指定了表。