sqlsafetext

Andrew Kuchling akuchlin at mems-exchange.org
Mon May 7 18:11:13 EDT 2001


"michael montagne" <montagne at boora.com> writes:
>          #print strText
>          import string
>          #replace single quotes with double single quotes
>          string.replace(strText,chr(39),chr(39) + chr(39))
>          #replace double quotes with double double quotes
>          string.replace(strText,chr(34),chr(34)+ chr(34))
>          #wrap in single quotes
>          strtemp="'" + strtemp + "'"
>          return strText

Providing the actual error you saw would allow actually figuring out
the problem, but I'm pretty sure it's that you aren't assigning
strtemp an initial value, for a start.  string.replace() 
returns the new value; it doesn't magically mutate the string.  So 
your code should be 'strtemp = string.replace(strText, ...)'

--amk





More information about the Python-list mailing list