title: Python - Returning the output as a dictionary - MySQL
body: <p>I have coded a class to handle mysql connecting using the external modules but when I get data I want it to be returned like:</p>
  
  <pre><code>{ 'id': '1', 'username': 'Test'}
  </code></pre>
  
  <p>it's currently returned:</p>
  
  <pre><code>(1, u'Test')
  </code></pre>
  
  <p>The code which I use is:</p>
  
  <pre><code>def executeQuery(self, query):
      if(self.mysqlSuccess):
          cursor = self.cnx.cursor()
          cursor.execute(query)
          for row in cursor:
              print row
  executeQuery('SELECT * FROM `users`')
  </code></pre>