简体   繁体   中英

ProgrammingError: relation “users” does not exist - PostgreSQL

Just started using postgreSQL today alongside Python. I am trying to execute a query using the 'psycopg2' library but I am getting the following error: 'ProgrammingError: relation "users" does not exist'

In my pSQL cmd line I have can see my 'users' table all lowercase no capitalisation going on so not sure what's going on.. I will paste my query below. Thank you in advance for any help guys!

conn = psycopg2.connect(host="127.0.0.1", database="test", user="postgres", password="password")
    cur = conn.cursor()
    cur.execute('SELECT * FROM users WHERE username = %s AND password = %s', (username, password))

Note When I run \\dt I get the following

         List of relations
 Schema | Name  | Type  |  Owner
--------+-------+-------+----------
 public | users | table | postgres

This happened to me at work once, and I was informed that you probably should try the following:

python manage.py makemigrations, followed by python manage.py migrate. In my case there were no migrations to make but it has fixed my "relation does not exist" issue a few times!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM