title: Python mySQL - escaping quotes
body: <p>I have seen this question asked in various ways on this website, but none of them exactly addressed my issue.</p>
  
  <p>I have an sql statement with single quotes inside it, and am trying to use recommended practices before making database queries with it. So the statement is like</p>
  
  <pre><code>val2="abc 'dostuff'" 
  sql="INSERT INTO TABLE_A(COL_A,COL_B) VALUES(%s,'%s')" %(val1, val2)
  a_cursor.execute(sql)
  </code></pre>
  
  <p>However, when I run this, I get..</p>
  
  <pre><code>ProgrammingError: (1064,"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'dostuff'.
  </code></pre>
  
  <p>What am I doing wrong?
  Thanks very much
  Nupur</p>