You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The signatures and semantics of pgdb.connect() are hard to use and partly ambiguous (see the discussion in #77):
The dsn format host:dbname:user:password:opt cannot contain a port; the port can only be passed as part of host (host:port).
When both dsn and keyword parameters are given, they override each other in a non-obvious way.
Additional keyword arguments are converted to a connection string, which is passed as dbname. This fails when database is a URI, None values are passed as 'None', and bytes values as their Python representation.
In C, connections are made with PQconnectdbParams with a fixed set of keywords, so arbitrary connection parameters cannot be passed directly (see Use PQconnectdbParams instead of PQsetdbLogin #26).
Proposal: a clear signature like in other drivers (host, port, dbname/database, user, password, plus arbitrary libpq keywords), with keyword values passed directly via PQconnectdbParams instead of a connection string, None values ignored, and a conninfo string or URI as an alternative to the keywords. This would be a breaking change, so it is planned for 7.0.
I moved this to 6.4, since most of the proposal can be added without breaking existing code: passing arbitrary libpq connection parameters as keywords directly via PQconnectdbParams (ignoring None values), and accepting a conninfo string or URI as an alternative. The old host:dbname:user:password:opt format of the dsn parameter and the ambiguous combinations with keyword parameters will then emit a DeprecationWarning. Removing them is left for 7.0. The details of the new signature are still to be decided.
Activity
Cito commentedon Nov 23, 2026
I moved this to 6.4, since most of the proposal can be added without breaking existing code: passing arbitrary libpq connection parameters as keywords directly via
PQconnectdbParams(ignoringNonevalues), and accepting a conninfo string or URI as an alternative. The oldhost:dbname:user:password:optformat of thedsnparameter and the ambiguous combinations with keyword parameters will then emit aDeprecationWarning. Removing them is left for 7.0. The details of the new signature are still to be decided.