0
你好我想翻譯下面比較簡單的查詢SQLAlchemy的,但我得到SQL查詢翻譯SQLAlchemy的
('Unexpected error:', <class 'sqlalchemy.exc.InvalidRequestError'>)
SELECT model, COUNT(model) AS count FROM log.logs
WHERE SOURCE = "WEB" AND year(timestamp) = 2015 AND month(timestamp) = 1
and account = "Test" and brand = "Nokia" GROUP BY model ORDER BY count DESC limit 10
這是我寫的,但它無法正常工作。哪裏不對 ?
devices = db.session.query(Logs.model).filter_by(source=source).filter_by(account=acc).filter_by(brand=brand).\
filter_by(year=year).filter_by(month=month).group_by(Logs.model).order_by(Logs.model.count().desc()).all()
這裏的count()調用是否正確? 'Logs.model.count().desc()'它應該按'count'列排序嗎? – dm03514