Re: RFC: Extend psycopg2.connect to accept all valid parameters?

From: Jan Urbański <wulczer(at)wulczer(dot)org>
To: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
Cc: Fabian Knittel <fabian(dot)knittel(at)avona(dot)com>, psycopg(at)postgresql(dot)org
Subject: Re: RFC: Extend psycopg2.connect to accept all valid parameters?
Date: 2011-11-17 07:48:16
Message-ID: 4EC4BC40.3050903@wulczer.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

On 17/11/11 03:02, Daniele Varrazzo wrote:
> On Wed, Nov 16, 2011 at 10:23 PM, Daniele Varrazzo
> <daniele(dot)varrazzo(at)gmail(dot)com> wrote:
> I've implemented what discussed here and pushed in a separate branch:
> https://github.com/dvarrazzo/psycopg/commit/d2b67364fd2b0b192342281d24a7e3d0a4909980
>
> It's open for discussion. It is not as tested as the rest of the
> library, as there aren't many tests covering connect() in all the
> possible ways (as there should be as many databases on the other side
> to reply).

I think the correct solution would be to document the 'dsn' parameter to
psycopg2.connect and perhaps even encourage people using it.

This pushes the trouble of parsing out and interpreting parameters to
libpq, which is good, for in the end the important thing is that libpq
sees what you want it to see.

For instance, this patch (and AFAICS vanilla psycopg2 too) does not
handle usernames with spaces in them. Instead of implementing quoting as
expected by libpq, why not just let the user use a DSN that will work
equally with psql as with any other libpq app out there?

As for SQLAlchemy, you can use the connect_args argument to pass a DSN
to create_engine thusly:

e = create_engine('postgresql://', connect_args={'dsn': 'user=foo
sslrootcert=root.crt'})

Cheers,
Jan

In response to

Responses

Browse psycopg by date

  From Date Subject
Next Message Federico Di Gregorio 2011-11-17 08:31:46 Re: RFC: Extend psycopg2.connect to accept all valid parameters?
Previous Message Daniele Varrazzo 2011-11-17 02:02:14 Re: RFC: Extend psycopg2.connect to accept all valid parameters?