user_counts = session.query( UserModel.role, func.count(UserModel.role).label("total_counts") ).group_by( UserModel.role ).all() #THE ABOVE QUERY CAN OUTPUT DATA: # +-------------+----------------+ # | role | total_counts | # +-------------+----------------+ # | Admin | 100 | # | Super Admin | 50 | # | user | 1700 | # +-------------+----------------+
0 Comments