Re: RFC: Extend psycopg2.connect to accept all valid parameters?
От | Jan Urbański |
---|---|
Тема | Re: RFC: Extend psycopg2.connect to accept all valid parameters? |
Дата | |
Msg-id | 4EC4BC40.3050903@wulczer.org обсуждение исходный текст |
Ответ на | Re: RFC: Extend psycopg2.connect to accept all valid parameters? (Daniele Varrazzo <daniele.varrazzo@gmail.com>) |
Ответы |
Re: RFC: Extend psycopg2.connect to accept all valid parameters?
|
Список | psycopg |
On 17/11/11 03:02, Daniele Varrazzo wrote: > On Wed, Nov 16, 2011 at 10:23 PM, Daniele Varrazzo > <daniele.varrazzo@gmail.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
В списке psycopg по дате отправления: