Re: How do I use parameterized queries with LIKE?
От | Daniele Varrazzo |
---|---|
Тема | Re: How do I use parameterized queries with LIKE? |
Дата | |
Msg-id | CA+mi_8bD6PNf3CYDA3geq=gTT3JVbB7z7kK485QkYD_Bpi00QQ@mail.gmail.com обсуждение исходный текст |
Ответ на | How do I use parameterized queries with LIKE? ("W. Matthew Wilson" <matt@tplus1.com>) |
Ответы |
Re: How do I use parameterized queries with LIKE?
|
Список | psycopg |
On Mon, May 28, 2012 at 11:00 PM, W. Matthew Wilson <matt@tplus1.com> wrote: > But when I move the "matt" part out and use a %s symbol instead, I get > this error: > > ValueError: unsupported format character ''' (0x27) at index 73 > > What is the right solution here? If you have parameters in the query, % is used as placeholder prefix. You must use %% to include a literal % in the query: In [14]: cur.execute("""select email_address from customer where email_address like '%%' || %s || '%%'""", ('matt',)) or you can add the % to the value instead of the query: In [17]: cur.execute("""select email_address from customer where email_address like %s""", ('%matt%',)) Hope this helps, -- Daniele
В списке psycopg по дате отправления: