'Internal. Converts results to dict.'

def fetch_as_dict(self, formatted=0, as_utf8=0):

    result = self._cursor.fetchall()
    ret = []
    needs_formatting = self.needs_formatting(result, formatted)
    for r in result:
        row_dict = frappe._dict({})
        for i in range(len(r)):
            if needs_formatting:
                val = self.convert_to_simple_type(r[i], formatted)
            else:
                val = r[i]
            if (as_utf8 and (type(val) is text_type)):
                val = val.encode(u'utf-8')
            row_dict[self._cursor.description[i][0]] = val
        ret.append(row_dict)
    return ret
