MySQLdb + Python + quotes

Jeff Bauer jbauer at rubic.com
Tue May 9 17:54:55 EDT 2000


Lars Hoeyrup Jensen wrote:
> I use the MySQLdb module to make Python interact with 
> MySQL. I have a problem, when I try to insert strings 
> that contain special characters (here I primarily think 
> of quotes: ' and "). There _must_ be a smart
> way to escape these characters.

>>> import MySQLdb
>>> MySQLdb.escape_string("""some '"' quotes""")
'some \\\'\\"\\\' quotes'


Jeff Bauer
Rubicon Research




More information about the Python-list mailing list