How to Get the Mapped Class's Table Name

22 views
Skip to first unread message

Ji Zhang

unread,
Oct 23, 2012, 10:28:03 AM10/23/12
to sqlal...@googlegroups.com
Hi,

I need to mapper a class to table which contains a dynamic table name like tbl_data_20121023. When writing the __repr__ method, I want to print out the mapped table name. How to do that?

def __repr__(self):
    return '<%s: %s %s>' % (self.???tablename???, self.field1, self.field2)

Thanks.

Michael Bayer

unread,
Oct 23, 2012, 12:07:42 PM10/23/12
to sqlal...@googlegroups.com
from sqlalchemy.orm import class_mapper

mapper = class_mapper(MyClass)


--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/6LOjYpvWLi4J.
To post to this group, send email to sqlal...@googlegroups.com.
To unsubscribe from this group, send email to sqlalchemy+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.

Reply all
Reply to author
Forward
0 new messages