def show(): stateInitiation("state.txt") colorInitiation("color.txt") teamInitiation("team.txt") playerInitiation("player.txt") print("Initial Success") query1(1, 35, 40, 0, 0, 0, 0, 5, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0) query1(0, 35, 40, 0, 0, 0, 1, 5, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0) query1(0, 35, 40, 0, 0, 0, 0, 5, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0) query2("Orange") query3("FloridaState") query3("Duke") query4("NC", "Red") query4("NC", "DarkBlue") query5(13) add_player(1, 1, "yyyy", "xxxx", 1, 1, 1, 1, 1, 1) query1(0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) query2("b") query3("haha") query4("NC", "Red") query5(5) add_player(1, 60, "xxxxx", "yyyy", 20, 20, 10, 10, 5.3, 5.3) add_team("team_baldwin", 10, 3, 20, 0) add_state("N/A") add_color("perry-winkle") query1(1, 10, 30, 0, 0, 40, 0, 0, 6, 0, 0, 5, 0, 0.0, 10.0, 0, 0.0, 10.0) query2("Gold") query3("FloridaState") query4("FL", "Maroon") query5(8) return
def exercise(): engine = create_engine( "postgresql://*****:*****@localhost:5432/ACC_BBALL") DBsession = sessionmaker(bind=engine) session = DBsession() add_state(session, "test_state") add_color(session, "test_color") add_team(session, "test_team", 0, 0, 0, 0) query1(session, 1, 10, 38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) query1(session, 0, 10, 38, 1, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) query1(session, 0, 10, 38, 0, 0, 20, 1, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0) query1(session, 0, 10, 38, 0, 0, 20, 0, 0, 5, 1, 0, 5, 0, 0, 0, 0, 0, 0) query1(session, 0, 10, 38, 0, 0, 20, 0, 0, 5, 0, 0, 5, 1, 0, 5, 0, 0, 0) query1(session, 0, 10, 38, 0, 0, 20, 0, 0, 5, 0, 0, 5, 0, 0, 5, 1, 0, 5) query1(session, 0, 10, 38, 1, 0, 20, 0, 0, 5, 0, 0, 5, 0, 0, 5, 1, 0, 5) query1(session, 0, 10, 38, 0, 0, 20, 1, 0, 5, 0, 0, 5, 1, 0, 5, 1, 0, 5) add_player(session, 1, 1, "first_test", "last_test", 0, 0, 0, 0, 0, 3) query1(session, 0, 10, 38, 0, 0, 20, 1, 0, 5, 0, 0, 5, 1, 0, 5, 1, 0, 5) query1(session, 1, 10, 38, 1, 0, 20, 1, 0, 5, 1, 0, 5, 1, 0, 5, 1, 0, 5) query2(session, "Gold") query2(session, "Red") query2(session, "Green") query2(session, "NoExist") query3(session, "GeorgiaTech") query3(session, "NoExist") query4(session, "FL", "Gold") query4(session, "NC", "DarkBlue") query5(session, 12) query5(session, 10) query5(session, 50) return
def teamInitiation(filename): data = open(filename) for tuple in data: team_id, name ,state_id, color_id, wins, losses = tuple.split(' ') print(name, state_id, color_id, wins, losses) add_team(name, state_id, color_id, wins, losses) data.close() return
def main(): engine = create_engine( "postgresql://*****:*****@localhost:5432/ACC_BBALL") Player.__table__.drop(engine, checkfirst=True) Team.__table__.drop(engine, checkfirst=True) State.__table__.drop(engine, checkfirst=True) Color.__table__.drop(engine, checkfirst=True) Base.metadata.create_all(engine) DBsession = sessionmaker(bind=engine) session = DBsession() color_file = open("color.txt") color_lines = color_file.readlines() for line in color_lines: line_list = line.split() add_color(session, line_list[1]) color_file.close() state_file = open("state.txt") state_lines = state_file.readlines() for line in state_lines: line_list = line.split() add_state(session, line_list[1]) state_file.close() team_file = open("team.txt") team_lines = team_file.readlines() for line in team_lines: line_list = line.split() add_team(session, line_list[1], line_list[2], line_list[3], line_list[4], line_list[5]) team_file.close() player_file = open("player.txt") player_lines = player_file.readlines() for line in player_lines: line_list = line.split() add_player(session, line_list[1], line_list[2], line_list[3], line_list[4], line_list[5], line_list[6], line_list[7], line_list[8], line_list[9], line_list[10]) player_file.close() session.close() exercise()
def test(): print("TEST QUERY1:\n\n") query_funcs.query1(1, 15, 20, 0, 0, 0, 0, 10, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0); print("\n") query_funcs.query1(0, 10, 40, 0, 0, 0, 2, 10, 10, 1, 0, 5, 0, 0, 0, 0, 0, 0) print("TEST QUERY2:\n\n") query_funcs.query2("LightBlue") print("\n") print("[TEST] Non-exist") query_funcs.query2("Pink") print("TEST QUERY3:\n\n") query_funcs.query3("Duke") print("\n") query_funcs.query3("VirginiaTech") print("\n") print("[TEST] Non-exist") query_funcs.query3("Chinese") print("TEST QUERY4:\n\n") query_funcs.query4("NC", "Red") print("\n") query_funcs.query4("NC", "DarkBlue") print("\n") print("[TEST] Non-exist") query_funcs.query4("BB", "Orange") print("TEST QUERY5:\n\n") print("[TEST] Non-exist") query_funcs.query5(100) print("\n") query_funcs.query5(11) query_funcs.add_player(1, 1, "Jerome", "Robinson", 34, 19, 4, 3, 1.7, 0.4) query_funcs.add_player(2, 1, "Jer", "J'Robinson", 10, 20, 4, 3, 1.7, 0.4) query_funcs.add_team("A'AA", 3, 2, 3, 5) query_funcs.add_state("S'tateAAA") query_funcs.add_color("C'olor")