P
P
pcdesign2015-02-25 19:07:52
Flask
pcdesign, 2015-02-25 19:07:52

How to translate such a command into sqlalchemy?

SELECT dest , COUNT( dest ) 
                  FROM lan
                  GROUP BY `dest` ORDER BY COUNT( dest )  DESC 
                  LIMIT 0, 30


Actually a subject.
dest is a varchar text field

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
klinkin, 2015-02-26
@pcdesign

query = session.query(LanModel.dest, func.count(LanModel.dest)).group_by(LanModel.dest)
query = query.order_by(LanModel.dest.desc())
query = query.limit(30)
objs = query.all()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question