title: How do I use variables as attribute names when using python mysql connector
body: <p>I am trying to use variables in a python function to try and retrieve attributes with mysql connector</p>
  
  <p>It seems to work only when I specify the name of the attribute in the query itself</p>
  
  <pre class="lang-py prettyprint-override"><code>def insert(ids, added_attribute):
      insert = ''
      if len(ids) &gt; 0:
          #insert scpecified attributes wanted
          insert += ' AND (%s = %s' %(added_attribute, ids[0])
          #for loop for more than one specified specific attribute
          for id_index in range(1, len(ids)):
              insert += ' OR %s = %s' %(added_attribute, ids[id_index])
          insert += ')'#close parenthesis on query insert
      return insert
  
  def get(name, attributes = 0, ids = []):
      cursor = conn.cursor()
  
      #insert specific ids
      insert = insert(ids, "id")
  
      query = 'SELECT %s FROM (TABLE) WHERE (name = %s%s)'
  
      cursor.execute(query, (attributes, name, insert))
  
      data = cursor.fetchall()
      cursor.close()
      return data
  </code></pre>
  
  <p>I keep getting null as a return value</p>