New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add connection.get_dsn_parameters() #364

Merged
merged 3 commits into from Jul 1, 2016

Conversation

Projects
None yet
3 participants
@a1exsh
Copy link
Contributor

a1exsh commented Oct 30, 2015

No description provided.

@fogzot

This comment has been minimized.

Copy link
Member

fogzot commented Jan 31, 2016

Seems like a useful refactor. @dvarrazzo any reason to not merge this?

@dvarrazzo

This comment has been minimized.

Copy link

dvarrazzo commented on psycopg/connection_type.c in a4cbb08 Feb 1, 2016

Would it work with a closed connection too? It could be useful (if a connection dies, a generic function may create a new one similar)

This comment has been minimized.

Copy link

a1exsh replied Feb 1, 2016

Looking at the libpq code I expect it to work. Will test when I have a second.

@dvarrazzo

This comment has been minimized.

Copy link
Member

dvarrazzo commented Feb 1, 2016

The patch itself is ok: it merges with the other features @a1exsh has being implementing (e.g. parsing the dsn in C, I seem to remember: bug #363) and haven't really had time to get through all of them. I think we should, to acknowledge his work.

@a1exsh

This comment has been minimized.

Copy link
Contributor

a1exsh commented Feb 4, 2016

@dvarrazzo that doesn't work with a closed connection though: the memory gets deallocated by PQfinish() which we call from conn_close[_locked]().

@dvarrazzo

This comment has been minimized.

Copy link
Member

dvarrazzo commented Feb 4, 2016

Fine, in this case the guard is ok

@dvarrazzo

This comment has been minimized.

Copy link
Member

dvarrazzo commented Mar 3, 2016

Isn't this just equivalent to parse_dsn(conn.dsn)?

@a1exsh

This comment has been minimized.

Copy link
Contributor

a1exsh commented Mar 3, 2016

@dvarrazzo it is almost equivalent, but it will also reveal any implicit connection parameters such as client_encoding and any parameters which were passed in form of PG* environment variables.

For example, you might have completely empty dsn in the connection object, while still overriding the defaults with PGHOST/PORT/USER/etc. This you cannot learn from examining the connection object's dsn property, only by querying PGconn.

@dvarrazzo dvarrazzo merged commit 051e6d1 into psycopg:master Jul 1, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment