def save_room_on_database(room: Room): json = room.json() room_name = room.name pprint(json) try: with db_session: if (db.exists("select * from DB_Room where name = $room_name")): db_room = db.DB_Room.get(name=room_name) db_room.set(min_players=room.min_players) db_room.set(max_players=room.max_players) db_room.set(current_players={"current_players": room.get_users()}) db_room.set(rules=room.rules.json()) db_room.set(owner=room.get_owner()) db_room.set(status=room.get_status()) db_room.set(game={}) db_room.set(teams=json["teams"]) db_room.set(created=room.created) else: db.DB_Room( name=room_name, min_players=room.min_players, max_players=room.get_max_players(), current_players={"current_players": room.get_users()}, owner=room.get_owner(), status=room.get_status(), game={}, teams=json["teams"], created=room.created, rules=room.rules.json() ) except Exception as e: print(f"Something went wrong on the db, {e}")
def check_validation_code(email: EmailStr, code: str): return db.exists( 'SELECT * FROM Validation_Tuple v WHERE v.email=$email AND v.code=$code' )
def check_email(u: User): email = u.email return db.exists('SELECT * FROM DB_User u WHERE u.email=$email')
def check_email2(email: EmailStr): return db.exists('SELECT * FROM DB_User u WHERE u.email=$email')
def check_username(u: User): uname = u.username return db.exists('SELECT * FROM DB_User u WHERE u.username = $uname')