MySQLdb + Python + quotes
Martin Skøtt
mskott at image.dk
Tue May 9 18:14:00 EDT 2000
More information about the Python-list mailing list
Tue May 9 18:14:00 EDT 2000
- Previous message (by thread): MySQLdb + Python + quotes
- Next message (by thread): MySQLdb + Python + quotes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Lars Hoeyrup Jensen <robinhat at rhk.dk> writes: > 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. I'm looking for something precisely > like the Addslashes function in PHP; see this URL: Sorry, I don't know any PHP, but I solved your problem by doing it this way (I use PostgreSQL, but that shouldn't make a difference): titel = "'%s'" % form["titel"].value The form dictionary is created by the cgi module. The principle is to use string substitution and double quoting ("' '"). -- Many regards Martin Skøtt mskott at image.dk 'In a certain sense, all decent programming languages are equally powerfull' Dr. Alan Turing
- Previous message (by thread): MySQLdb + Python + quotes
- Next message (by thread): MySQLdb + Python + quotes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list