2

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?

klin
  • 99,138
  • 12
  • 177
  • 203
Marko Zadravec
  • 7,861
  • 10
  • 48
  • 86

1 Answers1

2

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?

klin
  • 99,138
  • 12
  • 177
  • 203