Michael Bayer wrote: > >> Which docs do I need to understand what all this means and where do I >> find them? > > that would be here: > http://www.sqlalchemy.org/docs/05/mappers.html?highlight=large%20collections#working-with-large-collections
Cool, so my model now looks like: Base = declarative_base(engine=engine) class Unit(Base): __tablename__ = 'units' id = Column(Integer,primary_key=True) name = Column(String) class Record(Base): __tablename__ = 'records' timestamp = Column(DateTime,primary_key=True) unit_id = Column(Integer,ForeignKey('units.id'),primary_key=True) unit = relation('Unit', backref=backref('records', order_by=timestamp.desc(), lazy='dynamic')) is_on = Column(Boolean) mode = Column(Integer) error = Column(Integer) set = Column(Integer) measured = Column(Integer) ...and I can get the latest record for a unit with: unit = session.query(Unit).filter(Unit.id==3).first() unit.records.first() ...which is excellent :-) Now, how would I get all the records for a particular timeframe for a unit, ordered oldest to newest? (eg: all the records for today, or all the records for 08:00-12:00 today) This needs to be as efficient as possible as each unit generates one record per minute, so once this has been up for a year, we're talking about 260,000-ish records, of which I only want, say 1,440 for the whole day or 240 for 08:00-12:00. 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 -~----------~----~----~----~------~----~------~--~---