On 05/28/2012 03:00 PM, W. Matthew Wilson wrote:
> This works just fine:
> cursor.execute("""select email_address from customer where
> email_address like '%matt%'""")
> 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?
So you need something like:
cursor.execute("""select email_address from customer where
email_address like %s""", ("matt",))
Note in particular the ("matt",). The parameters in this form need to be passed
as a tuple.
> Thanks for the help.
In response to
psycopg by date
|Next:||From: Daniele Varrazzo||Date: 2012-05-28 22:42:55|
|Subject: Re: How do I use parameterized queries with LIKE?|
|Previous:||From: W. Matthew Wilson||Date: 2012-05-28 22:00:03|
|Subject: How do I use parameterized queries with LIKE?|