[BioPython] Help formatting mysqld queries

Laurent Pierron Laurent.Pierron at loria.fr
Sun Dec 28 14:37:56 EST 2003


Le 22 déc. 03, à 18:21, Andrew Nunberg a écrit :

> I wish to execute the following query
> d.execute('select start,end from repeat_features where trace_id=%s and
> repeat like "%TERT001%"',trace_id)
>
> I can get around this by replacing the %TERT001% with more formatting
> Eg
> Like=r’%TERT001%’
> ...and repeat like “%s”,[trace_id,like]
>
> Is there a way to escape the % formatting character? I tried \ and that
> didn’t work

Use '%%' :
d.execute('select start,end from repeat_features where trace_id=%s and 
repeat like "%%TERT001%%"',trace_id)

See the documentation at :
http://www.python.org/doc/current/lib/typesseq-strings.html
>




More information about the BioPython mailing list