0

I have a codebase that relies on a connection to Postgres via a full self-contained connection URL. The Python codebase was working while on PG11 but after switching to PG14 the options in the connection URL are no longer recognized:

postgresql://username:password@host:port/database?&options=-csearch_path=my_schema&target_session_attrs=read-write&connect_timeout=5

specifically this part: ?&options=-csearch_path=my_schema&target_session_attrs=read-write&connect_timeout=5

The search_path is not recognized and therefore the schema my_schema is not set by default.

I have tried many possibilities including, but none seem to work:

  1. adding encoding to the space like ?&options=-c%20search_path=my_schema
  2. removing the leading & before the options
  3. removing the -c before search_path
  4. specifying search_path without options

1 Answer 1

1

You must have made a mistake. That URI is syntactically incorrect and won't work with any version of PostgreSQL. The problems are

  • ?& right after the database name, when it should be only ?

  • = in the first parameter value, when you have to URI-escape that to %3D

Besides, port is not a valid port number. I assume that you modified the actual URI before you posted it, which is a bad idea, because it may well hide some of your actual mistakes.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.