Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > using like and % in MySQLdb

Reply
Thread Tools

using like and % in MySQLdb

 
 
Dave Harrison
Guest
Posts: n/a
 
      08-07-2003
Im sure this is a really obvious problem but :

self.curs.execute(
"""SELECT * FROM user WHERE login LIKE '%%s%'""", [login]
)

will not work ... gives me an "unsupported format character ''' (0x27)"

escaping the %'s with % as the doco recommends wont work either.

however this :

self.curs.execute(
"""SELECT * FROM user WHERE login LIKE '%dave%'"""
)

does work

so what's the go ?
cheers
Dave

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQLdb LIKE '%%%s%%' problem gumbah Python 11 01-14-2009 04:34 PM
Is there some methods like 'datareader' in MySQLdb for handling massdata Jeremy.Chen Python 2 01-06-2009 01:00 PM
shelve like interface to MySQLdb Python 0 09-02-2004 09:09 PM
ZMySQLDA/MySQLdb: DON'T fix like this for Zope 2.7.0! Chris Withers Python 0 04-03-2004 05:28 PM
using like and % in MySQLdb Dave Harrison Python 5 08-07-2003 03:14 PM



Advertisments