On Aug 3, 2010, at 1:05 PM, phrrn...@googlemail.com wrote: > Say you have a denormalized table with columns phone1, phone2, phone3 > and you would like to map the class so that the .phones property is an > iterable. > e.g. if I have data like > user_id, phone1, phone2, phone3 > 1, 1234, 5678, 9012 > 2, 3456,7890,1234 > > I would like to say something like > for p in S.query(User).get(1).phones: > print p.ordinal, p.number > > and get this as output: > > 1 1234 > 2 5678 > 3 9012 > > While one could use an operator like SQL Server's UNPIVOT, I would be > quite happy to have the mapper do the magic. I was reading through the > examples/vertical.py source today so I think that what I want is > doable, I am just not sure how to approach it. I assume that I would > proxy a list-based relation?
you'd make a Phone object that takes the place of "Animal" in the dictlike.py example. So you'd need User->Phone->PhoneFact. > > pjjH > > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to sqlalch...@googlegroups.com. > To unsubscribe from this group, send email to > sqlalchemy+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.