From: | Rory Campbell-Lange <rory(at)campbell-lange(dot)net> |
---|---|
To: | Frank Millman <frank(at)chagford(dot)com> |
Cc: | psycopg(at)postgresql(dot)org |
Subject: | Re: Minor issue |
Date: | 2020-05-26 13:08:01 |
Message-ID: | 20200526130801.GA23081@campbell-lange.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | psycopg |
On 26/05/20, Frank Millman (frank(at)chagford(dot)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?
From | Date | Subject | |
---|---|---|---|
Next Message | Frank Millman | 2020-05-26 13:16:03 | Re: Minor issue |
Previous Message | Frank Millman | 2020-05-26 12:15:29 | Re: Minor issue |