3

I understand that I can set search_path for the db role used to log in, but is there a way to specify the schema at the URI level or something to that effect? I may be mistaken due to my PostgreSQL experience being only with the JDBC driver.

My current URI fails:

postgresql://app_user:pw@localhost/dev_db?currentSchema=app

psycopg2 is complaining about currentSchema being an invalid option

sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) invalid dsn: invalid connection option "currentSchema"
 (Background on this error at: http://sqlalche.me/e/f405)
Ilja Everilä
  • 50,538
  • 7
  • 126
  • 127
Nogurenn
  • 858
  • 3
  • 11
  • 28
  • You have tagged flask-sqlalchemy. Do you have model creations as well? – mad_ Sep 17 '18 at 20:52
  • There will be. I haven't written the models yet. I came across [this SO question](https://stackoverflow.com/questions/11873959/flask-sqlalchemy-postgresql-define-specific-schema-for-table) if we're talking about the schema option in models. – Nogurenn Sep 17 '18 at 20:55
  • 1
    Exactly, I dont think Postgres still support schema param in connection uri. Workaround would be to connect to the db and change the search path as you mentioned – mad_ Sep 17 '18 at 20:58
  • 1
    [Specifically](https://stackoverflow.com/a/49930672/918959) this answer but alternatives are also discussed. – Antti Haapala -- Слава Україні Sep 17 '18 at 21:38

0 Answers0