World Cup Database - Build a World Cup Database - WC Database not being picked up by CodeRoad

I have recently completed both insert_data.sh and the queries.sh files, and both function correctly in the terminal. The steps on Coderoad work when the insert_data.sh file is empty, but as soon as I enter something into that file, it says that I need to create a worldcup database even though it already exists.

Your code so far

Do not change code above this line. Use the PSQL variable above to query your database.

echo $($PSQL “TRUNCATE TABLE games, teams”)

cat games.csv | while IFS=‘,’ read YEAR ROUND WINNER OPPONENT WINNER_GOALS OPPONENT_GOALS
do
TEAM_1=$($PSQL “SELECT name FROM teams WHERE name=‘$WINNER’”)
if [[ $WINNER != “winner” ]]
then
if [[ -z $TEAM_1 ]]
then
INSERT_TEAM_1=$($PSQL “INSERT INTO teams(name) VALUES(‘$WINNER’)”)
if [[ $INSERT_TEAM_1 == “INSERT 0 1” ]]
then
echo Inserted into teams, $WINNER
fi
fi
fi

TEAM_2=$($PSQL “SELECT name FROM teams WHERE name=‘$OPPONENT’”)
if [[ $OPPONENT != “opponent” ]]
then
if [[ -z $TEAM_2 ]]
then
INSERT_TEAM_2=$($PSQL “INSERT INTO teams(name) VALUES(‘$OPPONENT’)”)
if [[ $INSERT_TEAM_2 == “INSERT 0 1” ]]
then
echo Inserted into teams, $OPPONENT
fi
fi
fi

TEAM_ID_WINNER=$($PSQL “SELECT team_id FROM teams WHERE name=‘$WINNER’”)
TEAM_ID_OPPONENT=$($PSQL “SELECT team_id FROM teams WHERE name=‘$OPPONENT’”)
if [[ $YEAR != “year” ]]
then
INSERT_GAMES=$($PSQL “INSERT INTO games(year, round, winner_id, opponent_id, winner_goals, opponent_goals) VALUES($YEAR, ‘$ROUND’, $TEAM_ID_WINNER, $TEAM_ID_OPPONENT, $WINNER_GOALS, $OPPONENT_GOALS)”)
if [[ $INSERT_GAMES == “INSERT 0 1” ]]
then
echo Inserted into games, $YEAR
fi
fi

done

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36

Challenge: World Cup Database - Build a World Cup Database

Link to the challenge:

Hey, i have the same issue. Did you solve it ?

Just out of curiousity, did you mess with the lines at the top of the file that said “do not touch”? It was code that actually seemed to load a separate testing database for testing purposes. Also, the database list “\l” showed a worldcuptest database… you didn’t delete that or anything, did you?

I just finished that project, and noticed those testing database entries, but didn’t touch them, and had no problem with the testing.