On Apr 10, 2006, at 3:06 AM, Sandro Dentella wrote:

In the cases I need to represent the resulting rowset in a table to allow peple to edit them. I don't find it any easy to loop over the result object, using the attributes and respecting the order the db outputs the rowset (I think mapper.select doesn't have an 'order by' option, probably due to the
way it handles return data?)


mapper has an order_by option:

http://www.sqlalchemy.org/docs/ adv_datamapping.myt#adv_datamapping_orderby

 Which is the correct way to print the rowset?
 Is there a way to loop over the complete rowset?


the rows you get back from a Mapper is basically just a list. you can use regular list iteration.

While it is pretty easy in the case user/address (apart from the ordering),
I don't see how to loop when multiple relations/properties where added
creating the mapper as in the example at the beginning of this e- mail: the objects attached to the user-object under the property 'addr' is different from that under the property 'cities' (different methods, .count() is present
only in 'addr', not in 'cities').

well you could do:

        users = m.select(<stuff>)
        for u in users:
                print u
                for a in u.addr:
                        print a
                for c in u.cities:
                        print c



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to