Allen, allen.fowler wrote: ... > To clarify: > > I am using SQLAlchemy's Declarative Base to fully define and create my > database. > > For instance, there is a simple class/table Records, and I would like > to define a class CurrentRecords that is implemented in the database > as a view on Records. > > In this way, I can avoid polluting my application code with filtering > out all the non-active records every time I want to query Records. > Just define CurrentRecords as a table, i.e. in my app one of my views is:
class Vconsumption(Base): __table__ = sa.Table(u'vconsumption', metadata, sa.Column(u'consumptionid', sa.Integer(), sa.ForeignKey(u'consumption.consumptionid'), primary_key=True), ... ) consumption = sao.relation(Consumption) And I relate it back to the real consumption table, but never write/flush the view and do have to have a unique key which you define as "primary key" to SA. Werner --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---