title: PyMySQL variables in queries
body: <p>I would like to have a connection between my python code and a SQL database. I have read several ways to do it , but I am failing to get the results.</p>
  
  <pre><code>conn = pymysql.connect(user=X,passwd=X,host=X,port=X,database=X, charset='utf8', autocommit=True)
  curs = conn.cursor()
  
  try:
      curs.execute('SELECT id,sing_name,bir_yr FROM singers_list WHERE bir_yr = ? ',year)
      data = curs.fetchall()       
      for i in data:
          yield " Data: " + str(i) + "&lt;br/&gt;"
  except:
      yield " Failed to get data from base&lt;br/&gt;"
  </code></pre>
  
  <p>Where <strong>year</strong> is an int python variable. I am getting the proper results with:</p>
  
  <pre><code>curs.execute('SELECT id,sing_name,bir_yr FROM singers_list)
  </code></pre>
  
  <p>Which means I am connecting successfully to the database . How can I include variables in queries ? (not only integers , but strings too or any type) </p>