I find myself occassionally in a situation where I have a table object (such as is retrieved by Metadata.tables
) and want to get the Mapper object which defines a mapping from some user-defined class to a Table (and then eventually the mapped Class)
In context, I have:
A
sqlalchemy.schema.Table
object;A
sqlalchemy.schema.MetaData
object;A
sqlalchemy.orm.session.Session
object representing the current session.
What I want is the sqlalchemy.orm.mapper.Mapper
object which defines a mapping between a user-defined class and the Table
object above. I can't find a way to get this via the docs or from inspecting these objects and their available methods. Is there any way to do this?