Commands show nothing (Learn Relational Databases by Building a Mario Database)

The list and display commands show nothing:

\l
\list

\d
\d table_name

However, they are taken as valid. What’s happening? :slight_smile:

Edit:

Now I’m stuck.

  1. Enter "\d second_table " into the prompt

second_database=> \d second_table

ctrl + enter

You should display the details of “second_table”

a. I reset the progress
b. I ensure I’m using the right DB

=> psql --username=freecodecamp dbname=second_database

c. I run the display command again

=> \d second_table

Nothing is displayed.

=> CREATE TABLE second_table();
ERROR: relation “second_table” already exists

=> ctrl + enter

You should display the details of “second_table”

It sounds like you tried most things - it looks like your doing it correct. Perhaps if you shared a screen shot, I could maybe see something we might be missing.

Just to be clear, you’re supposed to type \d second_table in the prompt and press enter - not ctrl + enter. I assume you did that, but I don’t see it in your code. It should look like this: second_database=> \d second_table (then press enter)

I’d just want to point out that this issue still seems to exist; I’m getting the same problem randomly with any command in PostgreSQL. I can do a proper command and get nothing back as a result, and the only way to fix this is to disconnect from PostgreSQL and connect back, though now I noticed I had to do this twice in order to get any command working.


mario_database=> UPDATE characters SET name='Toad' WHERE name='Toadstool';
mario_database=> SELECT * FROM characters;
mario_database=> SELECT * FROM characters;
mario_database=> SELECT * FROM characters;
mario_database=> SELECT * FROM characters;
mario_database=> \d
mario_database=> exit
codeally@a85a4a32bcb5:~/project$ psql --username=freecodecamp dbname=postgres
Border style is 2.
Title is " ".
Pager usage is off.
psql (12.9 (Ubuntu 12.9-2.pgdg20.04+1))
Type "help" for help.

postgres=> \l
                                   List of databases
+----------------+--------------+----------+---------+---------+-----------------------+
|      Name      |    Owner     | Encoding | Collate |  Ctype  |   Access privileges   |
+----------------+--------------+----------+---------+---------+-----------------------+
| mario_database | freecodecamp | UTF8     | C.UTF-8 | C.UTF-8 |                       |
| postgres       | postgres     | UTF8     | C.UTF-8 | C.UTF-8 |                       |
| template0      | postgres     | UTF8     | C.UTF-8 | C.UTF-8 | =c/postgres          +|
|                |              |          |         |         | postgres=CTc/postgres |
| template1      | postgres     | UTF8     | C.UTF-8 | C.UTF-8 | =c/postgres          +|
|                |              |          |         |         | postgres=CTc/postgres |
+----------------+--------------+----------+---------+---------+-----------------------+
(4 rows)

postgres=> \c mario_database 
You are now connected to database "mario_database" as user "freecodecamp".
mario_database=> \d
mario_database=>                         List of relations
+--------+-----------------------------+----------+--------------+
| Schema |            Name             |   Type   |    Owner     |
+--------+-----------------------------+----------+--------------+
| public | characters                  | table    | freecodecamp |
| public | characters_character_id_seq | sequence | freecodecamp |
+--------+-----------------------------+----------+--------------+
(2 rows)


mario_database=> 
mario_database=> \d characters
                                             Table "public.characters"
+----------------+-----------------------+-----------+----------+--------------------------------------------------+
|     Column     |         Type          | Collation | Nullable |                     Default                      |
+----------------+-----------------------+-----------+----------+--------------------------------------------------+
| character_id   | integer               |           | not null | nextval('characters_character_id_seq'::regclass) |
| name           | character varying(30) |           | not null |                                                  |
| homeland       | character varying(60) |           |          |                                                  |
| favorite_color | character varying(30) |           |          |                                                  |
+----------------+-----------------------+-----------+----------+--------------------------------------------------+

mario_database=> SELECT * FROM characters;
                               
+--------------+--------+------------------+----------------+
| character_id |  name  |     homeland     | favorite_color |
+--------------+--------+------------------+----------------+
|            1 | Mario  | Mushroom Kingdom | Red            |
|            2 | Luigi  | Mushroom Kingdom | Green          |
|            3 | Peach  | Mushroom Kingdom | Pink           |
|            5 | Bowser | Mushroom Kingdom | Green          |
|            7 | Yoshi  | Dinosaur Land    | Green          |
|            6 | Daisy  | Sarasaland       | Orange         |
|            4 | Toad   | Mushroom Kingdom | Red            |
+--------------+--------+------------------+----------------+
(7 rows)

Any idea what this could have to do with? Using Vivaldi on Windows.

Thanks for sharing @PixelDust - that does seem quite strange. You are connected, so I don’t know - I’ve never seen that happen. Have you tried another browser? CodeAlly officially supports Chrome, Safari, Firefox, and Opera I think.

Sorry for the late reply. It indeed seems like it has to do something with Vivaldi although it is built using Chromium so it’s a bit strange, but after switching to Chrome I haven’t had the same issue again. Hopefully someone googling can find this helpful one day.

2 Likes

hey all–
same issue (i believe). using brave, chrome, safari, firefox…
after completing each test, i am forced to \q back to shell and log back into psql --username=freecodecamp dbname=postgres in order to proceed to next test. after quitting and jumping back into psql the course will show “completed” and progress. This is madness. is there a fix?

tried resetting the course, no luck.

so I split the terminal, logged both into psql…
reset the “coderoad” tutorial, \q one of the terminals followed by “clear” in bash. unsplit the terminal and now errors have stopped. flows smoothly…
system no longer tells me that i should be logged into psql. :slight_smile:

I also run into the same issue.
image
All the command above are taken as valid as @ffv mentioned. I can’t seem to figure it out even after deleted the container in CodeAlly Dashboard.
Edit: I use Chrome.

I found why this is happening
I happes when you press CTRL + C shortcut on your keyboard
don’t know is it a bug or something, but if you avoid pressing CTRL + C this will never happen

And if it happens you can just exit and reconnect to psql :slight_smile:

Hope it Helps

2 Likes

I faced the same issue. Probably this is happening anytime you press CTRL + C;

After several attempts I deleted the terminal with the bin icon. Then reconnected to the DB.

It solved my problem.

1 Like

+1 to Ctrl-C being the issue.
Some commands hang / don’t return to the prompt after execution. I imagine most of us are used to terminating hung commands with Ctrl-C. Use ‘Enter’, it returns to the prompt without messing up stdout.