Re: Minor issue

Поиск
Список
Период
Сортировка
От Rory Campbell-Lange
Тема Re: Minor issue
Дата
Msg-id 20200526130801.GA23081@campbell-lange.net
обсуждение исходный текст
Ответ на Re: Minor issue  (Frank Millman <frank@chagford.com>)
Ответы Re: Minor issue
Список psycopg
On 26/05/20, Frank Millman (frank@chagford.com) wrote:
> On 2020-05-26 2:11 PM, Daniele Varrazzo wrote:
> > No, we don't want to add any intelligence in trying to figure out what
> > is into a query. If you are comfortable that you will be using always
> > the same pattern for comments you can easily clean the string yourself
> > before passing it to psycopg.
> > 
> > A better approach for you I guess would be to use named placeholders,
> > so that an a missing placeholder wouldn't require you to change the
> > arguments to execute.

> Ok, thanks.
> 
> Frank

I must be missing something, because this works for me:

    In [28]: d.query("""
        ...: select 
        ...:     1 as a
        ...:     /*
        ...:     ,2 as b
        ...:     */
        ...:     -- ,'hi' as c
        ...:     ,%s as d
        ...: """, ("a string", )).results
    Out[28]: [Record(a=1, d='a string')]

(d.query is a wrapper around cursor_create, execute and fetchall).

Does using %s instead of {}.format help solve the issue?



В списке psycopg по дате отправления:

Предыдущее
От: Frank Millman
Дата:
Сообщение: Re: Minor issue
Следующее
От: Frank Millman
Дата:
Сообщение: Re: Minor issue