title: Twisted MySQL adbapi return dictionary
body: <p>Is there any way to return dictionary result from adbapi query to MySQL?</p>
  
  <pre><code>[name: 'Bob', phone_number: '9123 4567']
  </code></pre>
  
  <p>Default returns tuple. </p>
  
  <pre><code>['Bob', '9123 4567']
  </code></pre>
  
  <p>For simple Python &amp; MySQL we can use <strong>MySQLdb.cursors.DictCursor</strong>. But how to use it with twisted adbapi</p>
  
  <hr>
  
  <p><strong>UPD:</strong> I solved it but I think there should be better way. My solution: just override *_runInteraction* method of <em>adbapi.ConnectionPool</em> class.</p>
  
  <pre><code>class MyAdbapiConnectionPool(adbapi.ConnectionPool):
  def _runInteraction(self, interaction, *args, **kw):
      conn = self.connectionFactory(self)
      trans = self.transactionFactory(self, conn)
      try:
          result = interaction(trans, *args, **kw)
          if(result and isinstance(result[0], (list, tuple))):
              colnames = [c[0] for c in trans._cursor.description]
              result = [dict(zip(colnames, item)) for item in result]         
          trans.close()
          conn.commit()
          return result
      except:
          excType, excValue, excTraceback = sys.exc_info()
          try:
              conn.rollback()
          except:
              log.err(None, 'Rollback failed')
          raise excType, excValue, excTraceback
  </code></pre>