Include Schema in psycopg2 Connection String

Include Schema in psycopg2 Connection String

April 6, 2025

Info from https://stackoverflow.com/questions/59298580/how-to-specify-schema-in-psycopg2-connection-method

If you are using the string form you need to URL escape the options argument:

postgresql://user:password@localhost:5432/database_name?options=-csearch_path%3Ddbo,public

This will connect to localhost to database database_name with public schema.