Is possible to mapping view with class using mapper in SqlAlchemy?

Finally I found it.

We can create class for sql view’s. Here is simple example.

class ViewName(Base):
    __table__ = Table('viewname', Base.metadata,
        Column('id', Integer, primary_key=True),
        Column('foreign_key', Integer, ForeignKey('sometablename.id'),
            autoload=True, autoload_with=engine
        )

That’s it. We can access “viewname” table using ViewName class.

Thank you for all who are respond me.

Leave a Comment