예제 #1
0
    def test_apply_avg(self):
        """Query.apply_avg(col)

        avg = session.query(Address).apply_avg(Address.bounces)

        """
        session = create_session()

        avgs = list(session.query(Address).values(func.avg(Address.bounces)))
        avg = avgs[0][0]
        assert avg > 0 and avg < 10

        avg = session.query(func.avg(Address.bounces)).one()[0]
        assert avg > 0 and avg < 10
예제 #2
0
    def test_apply_avg(self):
        """Query.apply_avg(col)

        avg = session.query(Address).apply_avg(Address.bounces)

        """
        session = create_session()

        avgs = list(session.query(Address).values(func.avg(Address.bounces)))
        avg = avgs[0][0]
        assert avg > 0 and avg < 10

        avg = session.query(func.avg(Address.bounces)).one()[0]
        assert avg > 0 and avg < 10
예제 #3
0
 def test_aggregate_2(self):
     query = create_session().query(func.avg(foo.c.bar))
     avg = query.filter(foo.c.bar < 30).one()[0]
     eq_(round(avg, 1), 14.5)
예제 #4
0
 def test_aggregate_2(self):
     query = create_session().query(func.avg(foo.c.bar))
     avg = query.filter(foo.c.bar < 30).one()[0]
     eq_(round(avg, 1), 14.5)