def get_match_info(match_id): match_info = connect.query_one( cur, 'SELECT * FROM game_info WHERE id_odsp = ' + to_str(match_id)) match_commentary = connect.query_mul( cur, 'SELECT * FROM events WHERE id_odsp = ' + to_str(match_info['id_odsp'])) return match_info, match_commentary
def get_match_info(team1, team2, season): match_info = connect.query_one( cur, 'SELECT * FROM game_info WHERE ht = ' + to_str(team1) + ' AND at = ' + to_str(team2) + ' AND season = ' + season) match_commentary = connect.query_mul( cur, 'SELECT * FROM events WHERE id_odsp = ' + to_str(match_info['id_odsp'])) return match_info, match_commentary
import csv import sys import connect import subprocess import sys import os # Connect to the PostGres Server cur = connect.connect() team1 = (sys.argv[1]) team2 = (sys.argv[2]) season = (sys.argv[3]) match_query = connect.query_one(cur, 'SELECT id_odsp FROM game_info WHERE ht = ' + to_str(team1) + ' AND at = ' + to_str(team2) + ' AND season = ' + season) match_id = match_query['id_odsp'] def get_match_ids(): match_ids = connect.query_mul(cur, 'SELECT DISTINCT id_odsp FROM game_info') return match_ids match_ids = get_match_ids() idx = 0 for i, mid in enumerate(match_ids): if match_id == mid['id_odsp']: idx = i break with open('url_lists/all_test.txt', 'w') as f:
def get_team_names(home_team, away_team, season): team_names = connect.query_one(cur, 'SELECT * FROM game_info WHERE ht = ' + to_str(home_team) + ' AND at = ' + to_str(away_team) + ' AND season = ' + season) date_str = team_names['date'].strftime("%B %d, %Y") team_names['date'] = date_str return team_names