code: def sql_to_dict(self, query, param):
          
          cursor = connection.cursor()
          cursor.execute(query, param)
          fieldnames = [name[0] for name in cursor.description]
          result = []
          for row in cursor.fetchall():
              rowset = []
              for field in zip(fieldnames, row):
                  rowset.append(field)
              result.append(dict(rowset))
          return result
docs: Execute query and return a dict
  
          sql_to_dict(query, param) -> list of dicts
  
          code from snippet at http://www.djangosnippets.org/snippets/1383/