World Cup Database - Build a World Cup Database

Tell us what’s happening:
Describe your issue in detail here.
Hello when I try to execute the queries.sh file I get the error permission denied for table games please help

Your code so far

For queries.sh here’s the link to the code;
SQL/queries.sh at main · DennisWainaina/SQL (github.com)

Your browser information:

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

Challenge: World Cup Database - Build a World Cup Database

Link to the challenge:

1 Like

It looks like you can’t even access the table from the terminal?

1 Like

That’s the issue I can’t access the tables it keeps saying permission denied when I try to access the games table and also when I try to execute the queries.sh file

1 Like

Were you ever able to access the tables from the terminal? Or has it always been like that ever since you created them?
Also, how did you create them? Try to remember what you did exactly.

1 Like


I was able to create the tables and database and make the files executable but afterwards when I try to access the tables or to execute the queries.sh file I keep getting the error permission denied.

1 Like

You didn’t answer my questions?

I am trying to understand if something changed in your environment or if this has always been a problem for you.
Please post the code or method you used to create the tables.

1 Like

I’m new to this is there a way to access previous code as this is a project I’ve worked on for a quite a while every time starting the terminal again as to the method I used after logging in using freecodecamp as the username and postgres as the database name I created the database and the respective tables.
As to whether this has been a recurring problem so far I’ve not had a similar issue before here as previously I had worked on building a celestial bodies database a Mario Database and a student database succesfully without any issues.
Does this answer your question?

1 Like

How did you do this? Please post the code or describe the method you used.

1 Like

Here’s the sql file so far don’t know if that helps:
DennisWainaina/SQL: SQL mini projects (github.com)

1 Like

Can you share the code you used to insert data to the tables please?

Did your code start like this?


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

I cannot tell who is the current owner of the tables. It looks like the owner is Postgres not freecodecamp.

1 Like

Okay here’s the code used to insert data to the tables
SQL/insert_data.sh at main · DennisWainaina/SQL (github.com)

1 Like

if you go in and clear the data in all the tables and re-run the insert script, does it work?

The command to clear the data from the psql terminal is:
TRUNCATE TABLE games, teams;

I am wondering if your insert script will still work or not. (if it doesn’t, what errors does it give now)

1 Like

The insert script works perfectly but the queries script still says permission denied


The queries.sh started working after I put the code shown in the picture

Here’s the updated queries.sh but now there’s a problem where the output for the queries.sh is the same as the expected text but the test won’t pass.
SQL/queries.sh at main · DennisWainaina/SQL (github.com)

how did you confirm that you have the same output?
To make sure of it, you have to run the script and redirect the output to a file, then run a diff command against the output file and the expected_output.txt to see if there are any reported differences.

you can also redirect the output of the diff itself to a file if you want to share the output here

1 Like

I’ve redirected the output to a file with a link and a screenshot of the terminal which shows there are no differences between the two:
SQL/differences .txt at main · DennisWainaina/SQL (github.com)

1 Like

can you clarify which tests are not passing right now?

@moT01 pls take a look if you have time

In your database dump, I see ALTER … OWNER TO postgres in a number of places - the tables and some of the other things are owned by postgres, not freecodecamp. The script uses freecodecamp so it can’t access the tables - and if you log in with freecodecamp in the terminal, you won’t be able to access them either it looks like. Perhaps you accidentally logged in with postgres and created the tables, not sure. But I changed all those OWNER TO postgres to OWNER TO freecodecamp in your database dump, rebuilt the database, and all the tests passed with your two scripts. That should work for you @DennisWainaina.

Or, if you want to have some more fun, you could log in the terminal with postgres (psql -U postgres) and figure out how to change the table owners through the terminal.