8000 Add parse_dsn module function by a1exsh · Pull Request #321 · psycopg/psycopg2 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add parse_dsn module function #321

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

Merged
merged 5 commits into from
Oct 1, 2015

Conversation

a1exsh
Copy link
Contributor
@a1exsh a1exsh commented Jun 1, 2015

Calls PQconninfoParse to parse the dsn into a list of keyword and value
structs, then constructs a dictionary from that. Can be useful when one
needs to alter some part of the the connection string reliably, but
doesn't want to get into all the details of parsing a dsn string:
quoting, URL format, etc.

Calls PQconninfoParse to parse the dsn into a list of keyword and value
structs, then constructs a dictionary from that.  Can be useful when one
needs to alter some part of the the connection string reliably, but
doesn't want to get into all the details of parsing a dsn string:
quoting, URL format, etc.
@@ -91,6 +92,17 @@ The module interface respects the standard defined in the |DBAPI|_.
The parameters *connection_factory* and *async* are Psycopg extensions
to the |DBAPI|.

.. function:: parse_dsn(dsn)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function should be exposed by psycopg2.extensions, not the main module.

@dvarrazzo
Copy link
Member

Thank you for the contribution.

The patch needs tests, both failing and successful, and possibly with some tricky values (quotes, non-quotes, spaces etc).

@a1exsh
Copy link
Contributor Author
a1exsh commented Jun 1, 2015

Excellent points, thank you! I will have another look on it and re-submit.

@a1exsh
Copy link
Contributor Author
a1exsh commented Jun 1, 2015

I've addressed your feedback on this patch, please have a look when you got a minute.

@dvarrazzo
Copy link
Member

Thank you, it seems much better.

@a1exsh
Copy link
Contributor Author
a1exsh commented Jun 1, 2015

Good catch with libq version. I think it's just a matter of exposing PQlibVersion in python and having @skip_before_libpq decorator?

@dvarrazzo
Copy link
Member

Exposing the libpq version is another thing we should have done for a long time, see issue #35.

We sort of dragged it because at the time of opening the likelyhood of that function not being available was high, but now we are planning several features for psycopg 2.7 requiring a more modern libpq so I guess it's time to implement it.

@dvarrazzo dvarrazzo added this to the psycopg 2.7 milestone Jun 2, 2015
@a1exsh
Copy link
Contributor Author
a1exsh commented Oct 1, 2015

Hey Daniele, could you please merge this? We could really use reliable DSN parsing in #322 in order to specify the replication=true|database correctly. Thanks!

@dvarrazzo
Copy link
Member

Ok, I'll give it a final review and merge it.

@dvarrazzo dvarrazzo merged commit d604127 into psycopg:master Oct 1, 2015
@dvarrazzo
Copy link
Member

I've made a few fixes and merged, thank you very much.

@a1exsh a1exsh deleted the feature/parse-dsn branch October 1, 2015 12:56
@dvarrazzo dvarrazzo mentioned this pull request Jun 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0