mpope9 / nba-sql

:basketball: An application to build an NBA database backed by MySQL, Postgres, or SQLite
Apache License 2.0
171 stars 20 forks source link

PGTT Loading Error #97

Closed mpope9 closed 10 months ago

mpope9 commented 10 months ago

There is some kind of key error that is exposed when the headers section from the request doesn't match up with the underlying DB object. This wasn't exposed as an issue before because they always lined up when this was initially written. Some form of resilience is probably good to have.

mpope9 commented 10 months ago
Traceback (most recent call last):
  File "/Users/boneSaw/Projects/nba-sql/stats/nba_sql.py", line 350, in <module>
    main(args, False)
  File "/Users/boneSaw/Projects/nba-sql/stats/nba_sql.py", line 305, in main
    default_mode(settings, create_schema, request_gap, seasons, skip_tables, quiet or from_gui)
  File "/Users/boneSaw/Projects/nba-sql/stats/nba_sql.py", line 196, in default_mode
    pgtt_requester.generate_rows(season_id)
  File "/Users/boneSaw/Projects/nba-sql/stats/player_general_traditional_total.py", line 42, in generate_rows
    column_mapping = get_rowset_mapping(result_sets, column_names)
  File "/Users/boneSaw/Projects/nba-sql/stats/utils.py", line 21, in get_rowset_mapping
    return {column: headers.index(column.upper()) for column in column_names}
  File "/Users/boneSaw/Projects/nba-sql/stats/utils.py", line 21, in <dictcomp>
    return {column: headers.index(column.upper()) for column in column_names}
ValueError: 'CFID' is not in list

stack trace for reference. New headers returned by the API

'resultSets': [{'name': 'LeagueDashPlayerStats', 'headers': ['PLAYER_ID', 'PLAYER_NAME', 'NICKNAME', 'TEAM_ID', 'TEAM_ABBREVIATION', 'AGE', 'GP', 'W', 'L', 'W_PCT', 'MIN', 'FGM', 'FGA', 'FG_PCT', 'FG3M', 'FG3A', 'FG3_PCT', 'FTM', 'FTA', 'FT_PCT', 'OREB', 'DREB', 'REB', 'AST', 'TOV', 'STL', 'BLK', 'BLKA', 'PF', 'PFD', 'PTS', 'PLUS_MINUS', 'NBA_FANTASY_PTS', 'DD2', 'TD3', 'WNBA_FANTASY_PTS', 'GP_RANK', 'W_RANK', 'L_RANK', 'W_PCT_RANK', 'MIN_RANK', 'FGM_RANK', 'FGA_RANK', 'FG_PCT_RANK', 'FG3M_RANK', 'FG3A_RANK', 'FG3_PCT_RANK', 'FTM_RANK', 'FTA_RANK', 'FT_PCT_RANK', 'OREB_RANK', 'DREB_RANK', 'REB_RANK', 'AST_RANK', 'TOV_RANK', 'STL_RANK', 'BLK_RANK', 'BLKA_RANK', 'PF_RANK', 'PFD_RANK', 'PTS_RANK', 'PLUS_MINUS_RANK', 'NBA_FANTASY_PTS_RANK', 'DD2_RANK', 'TD3_RANK', 'WNBA_FANTASY_PTS_RANK']