From e3961f03a959b8fa6c30cb7138a7894f74191d9d Mon Sep 17 00:00:00 2001 From: Brian Warren Date: Fri, 25 Aug 2017 18:22:45 -0500 Subject: [PATCH] More verbose script for nfldb-update workaround --- nfldb-update_with_workaround.sh | 26 ++++++++++++++++++++++++++ update_nfldb_with_workaround.sh | 8 -------- 2 files changed, 26 insertions(+), 8 deletions(-) create mode 100644 nfldb-update_with_workaround.sh delete mode 100644 update_nfldb_with_workaround.sh diff --git a/nfldb-update_with_workaround.sh b/nfldb-update_with_workaround.sh new file mode 100644 index 0000000..c329a93 --- /dev/null +++ b/nfldb-update_with_workaround.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +# This is a workaround for an error that occurs when running 'nfldb-update' where some of the JSON data it +# gets from the internet contains "JAX" instead of "JAC" as the key for the Jacksonville Jaguars team + +# Workaround + +# Temporarily add a new team with the bad key +psql --username=nfldb nfldb --command="INSERT INTO team VALUES ('JAX', 'Jacksonville', 'Jaguars')" + +# Run nfldb-update - shouldn't have the error since it finds a matching team with bad key, "JAX" +nfldb-update + +# Check which tables have been populated with the bad key: +psql --username=nfldb nfldb --command="SELECT COUNT(*) FROM play WHERE pos_team = 'JAX'" +psql --username=nfldb nfldb --command="SELECT COUNT(*) FROM drive WHERE pos_team = 'JAX'" +psql --username=nfldb nfldb --command="SELECT COUNT(*) FROM game WHERE home_team = 'JAX'" +psql --username=nfldb nfldb --command="SELECT COUNT(*) FROM game WHERE away_team = 'JAX'" +psql --username=nfldb nfldb --command="SELECT COUNT(*) FROM player WHERE team = 'JAX'" +psql --username=nfldb nfldb --command="SELECT COUNT(*) FROM play_player WHERE team = 'JAX'" + +# Fix all the tables where the bad key appears +psql --username=nfldb nfldb --command="UPDATE play SET pos_team = 'JAC' WHERE pos_team = 'JAX'" + +# Delete the team with the bad key +psql --username=nfldb nfldb --command="DELETE FROM team WHERE team_id = 'JAX'" \ No newline at end of file diff --git a/update_nfldb_with_workaround.sh b/update_nfldb_with_workaround.sh deleted file mode 100644 index a114444..0000000 --- a/update_nfldb_with_workaround.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -# This is a workaround for an error that occurs when running 'nfldb-update' where some of the JSON data it -# gets from the internet contains "JAX" instead of "JAC" as the key for the Jacksonville Jaguars team -psql --username=nfldb nfldb --command="INSERT INTO team VALUES ('JAX', 'Jacksonville', 'Jaguars')" -nfldb-update -psql --username=nfldb nfldb --command="UPDATE play SET pos_team = 'JAC' WHERE pos_team = 'JAX'" -psql --username=nfldb nfldb --command="DELETE FROM team WHERE team_id = 'JAX'" \ No newline at end of file