def register_user(username, password):
    if (len(username) < 5):
        return False
    if (len(password) < 6):
        return False

    session = Session()
    users = session.query(User).filter(User.username == username).all()

    unique_name = len(users) == 0

    if unique_name:
        new_user = User(username, password)
        session.add(new_user)
        session.commit()

    session.close()
    return unique_name
game8 = Game(datetime(2020, 10, 8, 21, 0))
game9 = Game(datetime(2020, 10, 10, 13, 0))
game10 = Game(datetime(2020, 10, 12, 17, 0))
game11 = Game(datetime(2020, 10, 14, 20, 0))
game12 = Game(datetime(2020, 10, 15, 18, 0))

#6 - create users
user1 = User("GyozaCrumb", "password1")
user2 = User("socho", "password2")
user3 = User("corgo", "password3")
user4 = User("gabin", "password4")

league1.games = [game1, game2, game3, game4]
league2.games = [game5, game6, game7, game8]
league3.games = [game9, game10, game11, game12]

league1.members = [user1, user2, user3]
league2.members = [user1, user2, user3, user4]
league3.members = [user1, user3]

session.add(league1)
session.add(league2)
session.add(league3)

session.commit()
session.flush()
game1.winner = user1.id
game2.winner = user2.id
game3.winner = user1.id
session.commit()
session.close()