bar = relationship('Bar')


class Bar(Base):
    __tablename__ = 'bar'
id = Column(Integer, primary_key=True)

@hybrid_property
def foo_count(self):
    return object_session(self).query(Foo).filter(Foo.bar == self).count()

@foo_count.expression
def foo_count(cls):
    return select([func.count(Foo.id)]).where(Foo.bar_id == cls.id).label(
        'foo_count')
SQLAlchemy - How can I make eager loading count property