title: define parameter in update query in python psycopg2
body: <p>This my python code which is used to perform update operation from reading the csv file. I tried with <a href="http://speeves.erikin.com/2010/09/python-update-query-with-psycopg2.html" rel="nofollow">this</a> also. It doesn't work out.</p>
  
  <pre><code>for i  in cin:
      try:
          conn=psycopg2.connect("dbname=pharmaflare user=postgres")
          cursor=conn.cursor()
          cursor.execute("UPDATE pharmaflare_drug_interaction SET se_interaction ='%s' WHERE primary_drug ='%s' AND secondary_drug ='%s' AND side_effect ='%s'"%(i[3],i[0],i[1],i[2]))
          conn.commit()
          cursor.close()
          conn.close()
          #print "done",i[0],i[1],i[2],i[3]
      except Exception as e:
          cerr.writerow(i)
          ferr.flush()
          traceback.print_exc(file=sys.stdout)
          continue
  </code></pre>
  
  <p>Here I am facing the exception like syntax error due to the QUOTE's problem:
  Wherever the single quotes presents this exception arises.</p>
  
  <pre><code>  Traceback (most recent call last):
    File "&lt;ipython console&gt;", line 5, in &lt;module&gt;
    ProgrammingError: syntax error at or near "S"
    LINE 1: ...secondary_drug ='NEUER' AND side_effect ='MENIERE'S DISEASE'
  </code></pre>
  
  <p>Is there any alternative way available to define query statement without troubling the Quotes problem?</p>