database.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:odrs-web 作者: GNOME 项目源码 文件源码
def get_users_by_karma(self, best=True):
        """ Returns interesting statistics for the webapp """
        try:
            cur = self._db.cursor()
            if best:
                cur.execute("SELECT user_id, date_created, "
                            "user_hash, karma, is_banned FROM users "
                            "WHERE karma != 0 ORDER BY karma DESC LIMIT 10;")
            else:
                cur.execute("SELECT user_id, date_created, "
                            "user_hash, karma, is_banned FROM users "
                            "WHERE karma != 0 ORDER BY karma ASC LIMIT 10;")
        except mdb.Error as e:
            raise CursorError(cur, e)
        results = cur.fetchall()
        data = []
        for res in results:
            data.append(_create_user(res))
        return data
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号