On Wed, Feb 6, 2013 at 11:32 AM, Dhruv Baldawa <dhruvbald...@gmail.com>wrote:
> I would do a: > > class Consultation(Base): > __tablename__ = 'consultation' > > id = Column(Integer, primary_key=True) > patient_id = Column(Integer, ForeignKey('patient.id')) > doctor_id = Column(Integer, ForeignKey('doctor.id')) > date = Column(Date(), default=MyT.today()) > > @property > def consultation_count(self): > ''' returns the consultation count for current date ''' > return self.query.filter_by(date=self.date).count() # the syntax > might not be correct > > c = Consultation.query.get(1) > print c.consultation_count > > This way its computed on the fly and you dont need to store it. > If I read your code correctly this would mean: (a) the consultation_count property for all the consutlations that happened on a given day will be the same value (b) for a given row this value will keep changing as we insert more records into the table. So this will not work, no? _______________________________________________ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers