From: | Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com> |
---|---|
To: | Federico Di Gregorio <fog(at)dndg(dot)it> |
Cc: | psycopg(at)postgresql(dot)org |
Subject: | Re: RFC: Extend psycopg2.connect to accept all valid parameters? |
Date: | 2011-11-17 09:49:06 |
Message-ID: | CA+mi_8b5VEYFCLBUiJH1ijaz+JjPugdJuyWU+6B=2s4=e7a3kg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | psycopg |
On Thu, Nov 17, 2011 at 8:31 AM, Federico Di Gregorio <fog(at)dndg(dot)it> wrote:
> Looks good but I have a question: does automatic conversion always
> generates a valid connection string? Do we need quoting for some of the
> parameters?
No: just find the docs of the connection string escaping rule. They
are not implemented in psycopg, neither before the patch.
> The main idea behind .connect() was to use dsn for the
> generic case and provider keyword arguments as a utility for the most
> common cases while the patch actually says "it's ok to use kwargs for
> everything" and if we do that then it should work out of the box.
>
> But I almost always use username+password only so I don't know if some
> parameters need special treatment.
PQconnectdb says: To write an empty value, or a value containing
spaces, surround it with single quotes, e.g., keyword = 'a value'.
Single quotes and backslashes within the value must be escaped with a
backslash, i.e., \' and \\.
I'd rather do this in Python than in C, so at this point the patch is
basically what I've written yesterday minus the **kwargs pass-through.
Or, alternatively, a few hundred lines of C with dynamic memory
allocation, tricky conversion of Python objects to byte strings and a
couple of off-by-one errors peppered in less tested code paths...
-- Daniele
From | Date | Subject | |
---|---|---|---|
Next Message | Daniele Varrazzo | 2011-11-17 09:58:23 | Re: RFC: Extend psycopg2.connect to accept all valid parameters? |
Previous Message | Daniele Varrazzo | 2011-11-17 09:40:22 | Re: RFC: Extend psycopg2.connect to accept all valid parameters? |