SQLAlchemy count the number of rows with distinct values in column `name` of table `Tag`,session.query(Tag).distinct(Tag.name).group_by(Tag.name).count()