I got stucked in the tutorial part where I need to truncate “majors” table and re-execute insert_data.sh. I did what it describes. The result shows 3 rows in the table as well, however the tutorial won’t pass. Can somebody telling me what is wrong here?
code in insert_data-sh
# Script to insert data from courses.csv and students.csv into students database
PSQL="psql -X --username=freecodecamp --dbname=students --no-align --tuples-only -c"
cat courses_test.csv | while IFS="," read MAJOR COURSE
if [[ $MAJOR != "major" ]]
# get major_id
MAJOR_ID=$($PSQL "SELECT major_id FROM majors WHERE major='$MAJOR'")
# if not found
if [[ -z $MAJOR_ID ]]
# insert major
INSERT_MAJOR_RESULT=$($PSQL "INSERT INTO majors(major) VALUES('$MAJOR')")
if [[ $INSERT_MAJOR_RESULT == "INSERT 0 1" ]]
echo Inserted into majors, $MAJOR
# get new major_id
# get course_id
# if not found
# insert course
# get new course_id
# insert into majors_courses
Thank you for your help.
The hints should tell you what to enter @NazaLearn. What are the instructions of the step you are stuck on?
If you’re convinced you’re doing it right, there’s a few steps you can try here to restart the step and try again. Sometimes the terminal settings need to be reset.
The hints were telling me the followings:
. Run your
insert_data.sh script by executing it
./insert_data.sh in the terminal and press enter
majors table should have three rows after running the script. If it doesn’t, there might be something wrong in the script. You can use the reset button to reset the lesson and run the script again
I check and I got 3 rows after running the .sh file.
I even reset, (re) TRUNCATE the table and re-execute the .sh command. However it still not let me pass.
Can you please tell me what did I do wrong? or what is actually required from this step?
It looks like you are doing it right. Are the tests running automatically? If not, you should try both of those steps in the link I shared to reset the step and settings.
If they are - I’m not quite sure what the problem is. I would try those steps either way. I guess one other thing in the tests is that it checks that you entered the command from the
project folder - I’m guessing you are doing that, but there’s a chance you aren’t. Can you share a screen shot?
The tests for that step check three things:
majors table has 3 rows
- You entered
./insert_data.sh in the terminal
- and that you entered that command from the
Idk what was going on…today i log-in to test your suggestion.
Before that I wanted to see if I can make it work by following the hint.
and it works! Anyway thank you for being patience helping me out
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.