X
X
xxxfdd2020-12-28 00:11:28
Python
xxxfdd, 2020-12-28 00:11:28

What is the mistake of protso I want to display the content?

psycopg2.errors.UndefinedTable: ERROR: relation "orders" does not exist
LINE 1: SELECT * FROM Orders WHERE id = 1
table Orders is
here code just want to display content

import psycopg2

con = psycopg2.connect(
        host='localhost',
        database='Drive_in',
        user='postgres',
        password='42661902',
        port=5432
)
cur = con.cursor()

cur.execute("SELECT * FROM Orders WHERE id = 1")

rows = cur.fetchall()
for i in rows:
    print(f"id{i[0]}name{i[1]}")
cur.close()
con.close()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2020-12-28
@melkij

ERROR: relation "orders" does not exist
LINE 1: SELECT * FROM Orders WHERE id = 1
table Orders exists

So do you have a table? Orders or orders? These are two different tables. You don't have an orders table and you are trying to access it. If you think that this is how you will access the Orders table - read the manual, it's not.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question