[DB-SIG] [parameter substitution] how to escape perecent?

Lukasz Szybalski szybalski at gmail.com
Wed Jun 7 18:28:12 CEST 2006


I am doing a parameter substitution, but when I execute the following
statement I get an error. Could you tell me how should i escape %
signs?

sql="select DATE_FORMAT(FROM_UNIXTIME(my_table.received_date),'%Y %M
%d,%H:%i') from my_table where my_table.from_email=%s"

then
c.execute(sql,('myemail at mydomain'))
or
c.execute(sql,(email))

I get an error :
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.3/site-packages/MySQLdb/cursors.py", line
137, in execute
    self.errorhandler(self, exc, value)
  File "/usr/lib/python2.3/site-packages/MySQLdb/connections.py", line
33, in defaulterrorhandler
    raise errorclass, errorvalue
ValueError: unsupported format character 'Y' (0x59) at index 59

Thank You
Lucas


More information about the DB-SIG mailing list