Search code examples
postgresqlherokuheroku-postgres

I can't view table date in Heroku Postgres


I have a an app deployed on Heroku based on this tutorial. https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world

I can't view all the data inside one of my tables. Is this a Postgres feature? I'm new to Postgres and DBs.

List of tables

my-heroku-app::DATABASE=> \dt
                 List of relations
 Schema |      Name       | Type  |     Owner      
--------+-----------------+-------+----------------
 public | alembic_version | table | ufzxxxxxxxxxxx
 public | followers       | table | ufzxxxxxxxxxxx
 public | message         | table | ufzxxxxxxxxxxx
 public | notification    | table | ufzxxxxxxxxxxx
 public | post            | table | ufzxxxxxxxxxxx
 public | user            | table | ufzxxxxxxxxxxx

But I get a strange output. However, this should be a table of users who've registered with my blog. I have created several users already and the other table foreign keys can successfully reference them.

SELECT * FROM user;

output:
      user      
----------------
 ufzxxxxxxxxxxx

When I SELECT from any other table I get the whole table as expected.

SELECT * FROM post;

output:
 id |       body        |         timestamp          | user_id | language 
----+-------------------+----------------------------+---------+----------
  1 | dfdf              | 2020-08-01 03:30:14.529142 |       1 | de
  2 | Hello World       | 2020-08-01 03:30:20.730316 |       1 | de
  3 | you               | 2020-08-05 22:50:34.305096 |       2 | de
  4 | aaa               | 2020-08-21 13:36:38.617855 |       4 | de
  5 | new post from aaa | 2020-08-21 13:49:09.278394 |       4 | de
  6 | adefbg            | 2020-08-23 04:13:46.77888  |       5 | de
  7 | sdvc              | 2020-08-23 04:13:49.32016  |       5 | de


Solution

  • You should not have named your table user because it conflicts with the user keyword.

    You can get around this problem by using one of these forms to disambiguate:

    select * from public.user;
    
    select * from "user";