World Cup Database - Build a World Cup Database

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

Screen Shot 2023-01-13 at 3.44.57 PM

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:

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

thank you. I didn’t know that before now.

1 Like

I’m not sure what command you used to get the page of tilde but in general to get back to the worldcup prompt you need to connect the psql terminal (the command is the regular psql command you should have used in other projects) and then use the connect command to connect to the worldcup database

After doing an intense Google search, I just typed the ‘q’ key and it took me right back to the ‘worldcup’ prompt.

1 Like