Re: string formatting using the % operator

2005-06-13 Thread Peter Hansen
Dan Sommers wrote: > Let the DB-API do more work for you: > > cursor = connection.cursor( ) > sql = """SELECT column2, columns3 FROM table WHERE name LIKE %s""" > values = ('%%%s%%' % searchterm,) # note that this is a tuple It looks like this might be a rare case where not using the

Re: string formatting using the % operator

2005-06-13 Thread William Gill
Dan Sommers wrote: > On Mon, 13 Jun 2005 15:12:54 GMT, > William Gill <[EMAIL PROTECTED]> wrote: > > >>I am using the % operator to create queries for a db app. It works fine >>when exact strings, or numbers are used, but some queries need partial >>matching that use the '%' as a wildcards. So f

Re: string formatting using the % operator

2005-06-13 Thread Dan Sommers
On Mon, 13 Jun 2005 15:12:54 GMT, William Gill <[EMAIL PROTECTED]> wrote: > I am using the % operator to create queries for a db app. It works fine > when exact strings, or numbers are used, but some queries need partial > matching that use the '%' as a wildcards. So for example the resultant > s

Re: string formatting using the % operator

2005-06-13 Thread harold fellermann
> to return 'WHERE name LIKE %smith%'I have tried using escapes, > character codes for the % sign, and lots of other gyrations with no > success. The only thing that works is if I modify searchterm first: > >searchterm = 'smith' >searchterm ='%'+'smith'+'%' >sql += 'WHE

Re: string formatting using the % operator

2005-06-13 Thread fargo
William Gill wrote: > I am using the % operator to create queries for a db app. It works fine > when exact strings, or numbers are used, but some queries need partial > matching that use the '%' as a wildcards. So for example the resultant > string should be 'WHERE name LIKE %smith%' (would ma

string formatting using the % operator

2005-06-13 Thread William Gill
I am using the % operator to create queries for a db app. It works fine when exact strings, or numbers are used, but some queries need partial matching that use the '%' as a wildcards. So for example the resultant string should be 'WHERE name LIKE %smith%' (would match silversmith, smithy, an