title: Python & Mysql : Select statement with variable
body: <p>Hi I was looking for a similar thread but couldn't find any so decided to post.
  Any hint or link would be appreciated.</p>
  
  <p>I'm using python 2.7 + MySQLdb, I made a sql statement but having a weird issue.</p>
  
  <p>【works】</p>
  
  <pre><code>Val3 = 1
  sql = """SELECT ValA FROM %s WHERE Val2 = %s AND Val3 = %s""" % (Val1, Val2, Val3)
  </code></pre>
  
  <p>【doesn't work】</p>
  
  <pre><code>Val3 = "variable"
  sql = """SELECT ValA FROM %s WHERE Val2 = %s AND Val3 = %s""" % (Val1, Val2, Val3)
  </code></pre>
  
  <p>When I use text as a variable sql statement doesn't get executed.</p>
  
  <p>(Note: no error message just gets treated like as if its not there)</p>
  
  <p>Does anyone know what the problem is?</p>