1

How do I specify the search_path while connecting to my postgres db using PQconnectdb? I want to set the search_path to my_schema. I'm currently using the following connection command:

PQconnectdb("host=localhost user=my_user password=my_password port=5432 dbname=my_db")
m7913d
  • 10,244
  • 7
  • 28
  • 56

1 Answers1

3

You could add the following to your connection info:

options='-csearch_path=my_schema'

So, it would become:

PQconnectdb("host=localhost user=my_user password=my_password port=5432 dbname=my_db options='-csearch_path=my_schema'")

Reference:

m7913d
  • 10,244
  • 7
  • 28
  • 56