Search code examples
postgresqlflaskflask-sqlalchemy

Why I am not getting my postgres user table data, while other tables are accessible


I am working on this flask based web app. While things are working fine in the app, I wanted to verify the same in my postgres database.

While I can access user data in my app, I am not able to see the same when I try to access while SQL command on the terminal. This problem is specific to the 'user' table, while other tables could be accessed normally on terminal too.

This is the result of my user query:

classroom=# SELECT * FROM user;
 user  
-------
 fatih
(1 row)

and this is some other table in the same database:

classroom=# SELECT * FROM course;
 id |            title            |   code   
----+-----------------------------+----------
  3 | Algorithms                  | COC2030
  4 | Web development using Flask | FLASK001
(2 rows)

I am expecting the same type of result as in the course table, as in the user table.


Solution

  • Assuming there are more columns or rows in the user table that you'd like to see, you could try:

    • Log in using the same user as the flask app.
    • Log in as user postgres and check if that changes things (sudo -u postgres psql classroom, or psql classroom postgres.)
    • Use the \dp command to see if there are column privileges.
    • Use the \dn+ command to see if there are row security policies.