Tell us what’s happening:
I already finished my WC database project, but I can’t proceed to submit it. Since the beginning I noticed whenever I edit my insert_file.sh file, the CodeRoad stops recognizing every completed step, even the most basic one ( You should create a database named worldcup
).
I thought about just downloading the files and submitting them, but I can’t either.
I tried to upload screenshots but I apparently can’t since I’m a new user.
Edit: Tried resetting CodeRoad, for a second it seemed like it worked except I still had to give .sh files executable permissions, and when I did, again coderoad tells me that I still have to create the worldcup database.
Your code so far
insert_info.sh:
#! /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.
cat games.csv | while IFS="," read year round winner opponent winner_goals opponent_goals
do
if [[ $year != "year" ]]
then
# ADD TO TEAMS
$($PSQL"INSERT INTO teams(name) VALUES('$winner')")
$($PSQL"INSERT INTO teams(name) VALUES('$opponent')")
# ADD TO GAMES
# find teams IDs
WINNER_ID=$($PSQL "SELECT team_id FROM teams WHERE name='$winner'")
OPPONENT_ID=$($PSQL "SELECT team_id FROM teams WHERE name='$opponent'")
# insert into table games
$($PSQL"INSERT INTO games(year, round, winner_id, opponent_id, winner_goals, opponent_goals) VALUES($year, '$round', $WINNER_ID, $OPPONENT_ID, $winner_goals, $opponent_goals)")
fi
# if not, add it
done
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36
Challenge: World Cup Database - Build a World Cup Database
Link to the challenge: