World Cup Database - Build a World Cup Database

Hi there,

when I run the tests I get this message:
SUBTASKS 1.1 :10 Your “insert_data.sh” script should add a row in the “games” table for each game

In my nsert_data.sh there is a code for insert data from .csv to games table and when i try to select the table, i can be able to get the data.

Please, help!

Your code so far

cat games.csv | while IFS="," read year round winner opponent winner_goals opponent_goals
do
if [[ $year != year ]]
then
GAMES_WINNER_ID=$($PSQL "SELECT team_id FROM teams WHERE name='$winner'")
GAMES_OPPONENT_ID=$($PSQL "SELECT team_id FROM teams WHERE name='$opponent'")
echo $($PSQL "INSERT INTO games(year, round, winner, opponent, winner_goals, opponent_goals, winner_id, opponent_id) VALUES ($year, '$round', '$winner', '$opponent', $winner_goals, $opponent_goals, $GAMES_WINNER_ID, $GAMES_OPPONENT_ID);")
fi
done

worldcup=> select * from games;
game_id | year | round | winner | opponent | winner_goals | opponent_goals | winner_id | opponent_id
---------±-----±--------------±------------±--------------±-------------±---------------±----------±------------
916 | 2018 | Final | France | Croatia | 4 | 2 | 1753 | 1754
917 | 2018 | Third Place | Belgium | England | 2 | 0 | 1755 | 1756
918 | 2018 | Semi-Final | Croatia | England | 2 | 1 | 1754 | 1756
919 | 2018 | Semi-Final | France | Belgium | 1 | 0 | 1753 | 1755
920 | 2018 | Quarter-Final | Croatia | Russia | 3 | 2 | 1754 | 1757
921 | 2018 | Quarter-Final | England | Sweden | 2 | 0 | 1756 | 1758
922 | 2018 | Quarter-Final | Belgium | Brazil | 2 | 1 | 1755 | 1759
923 | 2018 | Quarter-Final | France | Uruguay | 2 | 0 | 1753 | 1760
924 | 2018 | Eighth-Final | England | Colombia | 2 | 1 | 1756 | 1761
925 | 2018 | Eighth-Final | Sweden | Switzerland | 1 | 0 | 1758 | 1762
926 | 2018 | Eighth-Final | Belgium | Japan | 3 | 2 | 1755 | 1763
927 | 2018 | Eighth-Final | Brazil | Mexico | 2 | 0 | 1759 | 1764
928 | 2018 | Eighth-Final | Croatia | Denmark | 2 | 1 | 1754 | 1765
929 | 2018 | Eighth-Final | Russia | Spain | 2 | 1 | 1757 | 1766
930 | 2018 | Eighth-Final | Uruguay | Portugal | 2 | 1 | 1760 | 1767
931 | 2018 | Eighth-Final | France | Argentina | 4 | 3 | 1753 | 1768
932 | 2014 | Final | Germany | Argentina | 1 | 0 | 1769 | 1768
933 | 2014 | Third Place | Netherlands | Brazil | 3 | 0 | 1770 | 1759
934 | 2014 | Semi-Final | Argentina | Netherlands | 1 | 0 | 1768 | 1770
935 | 2014 | Semi-Final | Germany | Brazil | 7 | 1 | 1769 | 1759
936 | 2014 | Quarter-Final | Netherlands | Costa Rica | 1 | 0 | 1770 | 1771
937 | 2014 | Quarter-Final | Argentina | Belgium | 1 | 0 | 1768 | 1755
938 | 2014 | Quarter-Final | Brazil | Colombia | 2 | 1 | 1759 | 1761
939 | 2014 | Quarter-Final | Germany | France | 1 | 0 | 1769 | 1753
940 | 2014 | Eighth-Final | Brazil | Chile | 2 | 1 | 1759 | 1772
941 | 2014 | Eighth-Final | Colombia | Uruguay | 2 | 0 | 1761 | 1760
942 | 2014 | Eighth-Final | France | Nigeria | 2 | 0 | 1753 | 1773
943 | 2014 | Eighth-Final | Germany | Algeria | 2 | 1 | 1769 | 1774
944 | 2014 | Eighth-Final | Netherlands | Mexico | 2 | 1 | 1770 | 1764
945 | 2014 | Eighth-Final | Costa Rica | Greece | 2 | 1 | 1771 | 1775
946 | 2014 | Eighth-Final | Argentina | Switzerland | 1 | 0 | 1768 | 1762
947 | 2014 | Eighth-Final | Belgium | United States | 2 | 1 | 1755 | 1776
(32 rows)

Your browser information:

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

Challenge: World Cup Database - Build a World Cup Database

Link to the challenge:

if it helps, here is the test error log:

✘ SUBTASKS 1.1 :10 Your “insert_data.sh” script should add a row in the “games” table for each game

AssertionError [ERR_ASSERTION]: The expression evaluated to a false value:

assert(res.rowCount === 32 && finalRows.length === 2 && res2.rows[0].name === ‘France’)

at Context. (test/1.1.test.js:169:5)
at processTicksAndRejections (internal/process/task_queues.js:95:5)

Solved my self, too many columns on the table.

Thanks a lot