The MetaData object has a sorted_tables method/property that returns a
list of Table objects. Also, MetaData.tables[]  can be accessed by
table-name (fully qualified including schema, if any). Table.columns
has name and type information. Assuming a MetaData instance md, here
is how you would list the columns in the 'banana' table:
for i in md['banana'].columns:
  print i.name, i.type


Likewise, for a mapped class one can iterate over the mapped
properties:
from sqlalchemy.orm import class_mapper
for i in class_mapper(Banana).iterate_properties:
   print i

pjjH


On Jun 26, 12:24 pm, Didip Kerabat <did...@gmail.com> wrote:
> I believe you can look inside object's __dict__ for list of field names.
>
> There are plenty of information you can pull from orm.Mapper. Those are
> explained better here:
>
> http://www.sqlalchemy.org/docs/05/reference/orm/mapping.html
>
> - Didip -
>
> On Thu, Jun 25, 2009 at 6:12 PM, Chris Withers <ch...@simplistix.co.uk>wrote:
>
>
>
> > Hi All,
>
> > What's the correct way to find out what fields a model contains?
> > (eg: one that's been reflected from an existing table)
>
> > At this stage, I only care about the field names, if that makes things
> > easier...
>
> > Also, how would I do the same from a mapped object?
>
> > cheers,
>
> > Chris
>
> > --
> > Simplistix - Content Management, Zope & Python Consulting
> >            -http://www.simplistix.co.uk
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@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
-~----------~----~----~----~------~----~------~--~---

Reply via email to