python - 这个sql 查询能转换成sqlalchemy语句吗?
伊谢尔伦
伊谢尔伦 2017-04-17 11:26:20
0
1
888
select to_char(date_published, 'yyyymm') yo from blog group by yo;

date_published 是timestamp with time zone 类型数据

我用cast() 试了一下 , 可group_by 不知道如何使用

貌似只能用extract() 了

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(1)
左手右手慢动作

Resolved
You can directly call functions or stored procedures supported by the database through func

yonth = db.func.to_char(ArticleModel.date_published, 'yyyymm').label('yonth')
archive_list = (
    db.session.query(yonth, db.func.count(1)).group_by('yonth').all()
)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template