def todata(rs, fully_qualified=False, fmap=None): """Transmogrifies a result set into a list of dicts. If ``rs`` is a single instance, only a dict is returned. If ``rs`` is a list, a list of dicts is returned. :param rs: Data to transmogrify :param fully_qualified: Whether dict keys should be fully qualified (schema + '.' + table + '.' + column) or not (just column name) :rtype: Dict or list of dicts """ if isinstance(rs, (list, sqlalchemy.orm.query.Query)): data = [] for row in rs: data.append(todict(row, fully_qualified=fully_qualified, fmap=fmap)) return data else: return todict(rs, fully_qualified=fully_qualified, fmap=fmap)
def dump(self): from pysite.models import todict from pprint import pprint pprint(todict(self))