Re: RFC: Extend psycopg2.connect to accept all valid parameters?
От | Daniele Varrazzo |
---|---|
Тема | Re: RFC: Extend psycopg2.connect to accept all valid parameters? |
Дата | |
Msg-id | CA+mi_8b5VEYFCLBUiJH1ijaz+JjPugdJuyWU+6B=2s4=e7a3kg@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: RFC: Extend psycopg2.connect to accept all valid parameters? (Federico Di Gregorio <fog@dndg.it>) |
Ответы |
Re: RFC: Extend psycopg2.connect to accept all valid parameters?
Re: RFC: Extend psycopg2.connect to accept all valid parameters? |
Список | psycopg |
On Thu, Nov 17, 2011 at 8:31 AM, Federico Di Gregorio <fog@dndg.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
В списке psycopg по дате отправления: