baffling sql string

DarkBlue nomail at nixmail.com
Wed Sep 27 08:21:24 EDT 2006


Following is a code snippet from a pythoncard app
the problem is with the sql string called iq1
If either mysubject or mytalktext contains an 
apostrophe the update fails :
Example: mysubject="Let's Eat"  this fails
         mysubject="Lets Eat"   this works fine

What options do I have to avoid this issue but still
can use apostrophes in my input data ?

mysubject=self.components.TextField1.text  
mytalktext=self.components.TextArea1.text
mymsgno=self.myamsgno
iq1="update MSGTALK set msgdate='NOW',subject='%s',talktext='%s' where
msgno= %d " % (mysubject,mytalktext,mymsgno) 
try:
   self.cur.execute(iq1)
   con1.commit()
   self.components.TextArea2.appendText('Update ok\n')  
except:
   self.components.TextArea2.appendText('Problem during update command\n')            
   self.components.TextArea2.appendText(iq1)


(hope the intendation did not get too messed up )

Thanks 

   



More information about the Python-list mailing list