Re: RFC: Extend psycopg2.connect to accept all valid parameters?
От | Federico Di Gregorio |
---|---|
Тема | Re: RFC: Extend psycopg2.connect to accept all valid parameters? |
Дата | |
Msg-id | 4EC4ED95.9070904@dndg.it обсуждение исходный текст |
Ответ на | 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 10:49, Daniele Varrazzo wrote: > 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... Never said doing it in Python is wrong. In fact anything that isn't time-critical (type conversions, etc.) at this point is OK in Python. federico -- Federico Di Gregorio fog@initd.org Io non sono romantica. La candelina sul tavolo mi vede e si spegne. -- sisterconfusion
В списке psycopg по дате отправления: