美文网首页
flask-sqlalchemy join 查询

flask-sqlalchemy join 查询

作者: 暂时还没有昵称2222 | 来源:发表于2015-12-30 15:32 被阅读3642次

    代码如下:

    @cache.memoize(timeout=3600 * 12)
    def _get_activites(activity_type, today):
        query = Activity.query \
                        .join(ActivityType,
                              Activity.id == ActivityType.activity_id) \
                        .filter(ActivityType.show_type == activity_type,
                                Activity.is_publish == 1,
                                Activity.start <= today,
                                Activity.end > today) \
                        .order_by(Activity.publish_time)
        return query.all()
    

    相关文章

      网友评论

          本文标题:flask-sqlalchemy join 查询

          本文链接:https://www.haomeiwen.com/subject/flpihttx.html