Skip to content
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

Psycopg2cffi does not obfuscate passwords in connection dsn #84

Open
avanov opened this issue Aug 19, 2017 · 0 comments
Open

Psycopg2cffi does not obfuscate passwords in connection dsn #84

avanov opened this issue Aug 19, 2017 · 0 comments

Comments

@avanov
Copy link

avanov commented Aug 19, 2017

Hi!

It seems that there is a small difference in a way how psycopg2cffi and psycopg2 print connection DSNs. The former does not obfuscate passwords, and the latter does (http://initd.org/psycopg/docs/connection.html#connection.dsn).

pg_params = {
    'database': 'solo',
    'user': 'solo',
    'password': 'solo',
    'host': 'localhost',
    'port': 5432
}

conn = psycopg2.connect(**pg_params)

# Result for psycopg2
# "user=solo password=xxx dbname=solo host=localhost port=5432"

# Result for psycopg2cffi
# "dbname=solo user=solo password=solo host=localhost port=5432"

print(conn.dsn)

It is not a big issue by itself, yet it complicates testing of projects that might benefit from being able to supportpsycopg2cffi as a drop-in replacement for psycopg2, for instance, aiopg2 (I'm currently working on this support in aio-libs/aiopg#361).

Here's how psycopg2 obfuscates passwords:

P.S. It would be great if we could preserve the order of connection attributes as well

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

No branches or pull requests

1 participant