title: How to get a dictionary of data in column1 as key and column2 as the value?
body: <p><a href="https://stackoverflow.com/questions/4940670/pymysql-fetchall-results-as-dictionary">This question</a> in stack overflow answers how would one get dictionary from tables using pymysql. However, this method outputs column header as keys and its value as data in that column.</p>
  
  <p>Whats the best way to have actual data as keys and values?</p>
  
  <p>For example:</p>
  
  <pre><code> Name    |Age
   -------------
   John    |25
   Tom     |45
   Tammy   |18
  </code></pre>
  
  <p>I want</p>
  
  <pre><code>  {John:25, Tom:45, Tammy:18}
  </code></pre>
  
  <p>NOT  </p>
  
  <pre><code> [{Name:John},{Age:25},....]
  </code></pre>
  
  <p>This is what i have right now:</p>
  
  <pre><code>def name2dict(name_list):
      name_list_tuple = tuple(name_list)
      conn = pymysql.connect()
      cur = conn.cursor(pymysql.cursors.DictCursor)
      Name2pos = """SELECT Tables.ID, Tables.Position FROM Tables where Tables.Name in %s"""
      cur.execute(Name2pos, [name_list_tuple])
      query_dict = cur.fetchall()
      cur.close()
      conn.close()
      return query_dict
  </code></pre>