def users_stats(args): users = session.query(User).all() output = "" skel = "username: {} online: {}" for i in users: d = skel.format(i.username, i.online) output += d if output == "" else '\n' + d print(output)
def get_user(username): """ get_user(username) -> User or None Returns models.User object if user exists else None. """ query = session.query(User).filter(User.username == username) if query.count() == 0: return None else: return query.one()