using like and % in MySQLdb

Discussion in 'Python' started by Dave Harrison, Aug 7, 2003.

  1. 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
    Dave Harrison, Aug 7, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dave Harrison

    using like and % in MySQLdb

    Dave Harrison, Aug 7, 2003, in forum: Python
    Replies:
    5
    Views:
    418
    Chris
    Aug 7, 2003
  2. Chris Withers
    Replies:
    0
    Views:
    271
    Chris Withers
    Apr 3, 2004
  3. Guest
    Replies:
    0
    Views:
    281
    Guest
    Sep 2, 2004
  4. Patrick Kowalzick
    Replies:
    5
    Views:
    461
    Patrick Kowalzick
    Mar 14, 2006
  5. Jeremy.Chen
    Replies:
    2
    Views:
    342
    Jeremy.Chen
    Jan 6, 2009
Loading...

Share This Page