I am very sorry that I have to answer my question, but sometimes we just can’t wait for help. And since I found an answer and a good one, I feel obligated to share with the community. So here it is:
table = self.session.query(Table.var1, Table.var2, func.count(Table)).group_by(Table.var1, Table.var2).all()
(, , ). , . , , 296110 .28 , var1 var2 5 90 .
(2d):
def pprint_table():
colnames = list(set([i[1] for i in table]))
rows = defaultdict(lambda:[0]*len(colnames))
for r in table:
rows[r[0]][colnames.index(r[1])] = r[2]
print colnames, 'total'
for rn, r in rows.items():
print rn, r, sum(r)