hello all!

probably this was asked before, as I already grabbed some answers already from here and stackoverflow, but I don't really feel happy about it.

problem: i have a query that it's result must go directly as a json (web / rpc usage), and I wonder if I must go from the cycle .


class A(Base):
    attr_one = Column(..)
    attr_two = Column(..)
    attr_three = Column(..)
    attr_four = Column(..)
    attr_five = Column(..)

data = session.query(A.attr_one, A.attr_four)  # ok, got a query object
result = data.all()  # got a result proxy
wanted_result = map(lambda r: r._as_dict(), data.all()) # iterate through the result proxy, calling the _as_dict() method from row_proxy. it does the job, but is that really necessary?


my question is if there's any way of "simplifying" the query just for json purposes, since imho the need of some proxies here may be an overkill. but ... i might be wrong :)


best regards,
richard.

--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

<<attachment: richard.vcf>>

Reply via email to