Tell us what’s happening:
I’ve successfully gotten to the point where I’m adding 24 distinct rows to the teams table. I then went to select all the data from the ‘games’ table, and I just get ~ marks all the way down my terminal screen (see attached photo).
CTRL + c didn’t take me back to the ‘worldcup’ psql prompt. And CTRL + z disconnected me entirely from the database.
How do I get back to my ‘worldcup’ prompt after getting a screen full of ~ marks?
Your code so far
#! /bin/bash
if [[ $1 == "test" ]]
then
PSQL="psql --username=postgres --dbname=worldcuptest -t --no-align -c"
else
PSQL="psql --username=freecodecamp --dbname=worldcup -t --no-align -c"
fi
# Do not change code above this line. Use the PSQL variable above to query your database.
echo $($PSQL "TRUNCATE games, teams")
cat games.csv | while IFS="," read YEAR ROUND WINNER OPPONENT WINNER_GOALS OPPONENT_GOALS
do
if (( $YEAR != 'year' ))
then
echo **Year: $YEAR, Round: $ROUND, Winner: $WINNER, Opponent: $OPPONENT, Winner_Goals: $WINNER_GOALS, Opponent_Goals: $OPPONENT_GOALS
COUNT_WINNER=$($PSQL "select count(name) from teams where name='$WINNER'")
echo *COUNT_WINNER*: $COUNT_WINNER
if (( $COUNT_WINNER == 0 ))
then
echo winner not in teams table. will insert them here.
echo $($PSQL "insert into teams(name) values('$WINNER')")
fi
COUNT_OPPONENT=$($PSQL "select count(name) from teams where name='$OPPONENT'")
echo *COUNT_OPPONENT*: $COUNT_OPPONENT
if (( $COUNT_OPPONENT == 0 ))
then
echo opponent not in teams table. will insert them here.
echo $($PSQL "insert into teams(name) values('$OPPONENT')")
fi
#insert into games table order
fi
done
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36
Challenge: World Cup Database - Build a World Cup Database
Link to the challenge: