Reputation: 8730
I try to connect to Postgres database inside my Python app. I use psycopg2 library.
If I execute select statement like this:
cursor.execute("""select schema_name from information_schema.schemata;""")
rows = cursor.fetchall()
print(rows)
and I get :
[('DB_FZ',), ('DB_FZ_TEMP',), ...]
but if I execute statement
cursor.execute("""select * from DB_FZ.d_results;""")
rows = cursor.fetchall()
print(rows)
I get error
psycopg2.ProgrammingError: schema "db_fz" does not exist
LINE 1: select * from DB_FZ.d_results;
What could be wrong?
Upvotes: 2
Views: 2713
Reputation: 121594
The schema name is in uppercase, you should put it in double quotes:
cursor.execute("""select * from "DB_FZ".d_results;""")
See also Are PostgreSQL column names case-sensitive?
Upvotes: 2