def total_server(self, server): """查询服务器""" db_config = server_util.str_to_dbconfig(server.db_connect) connect = get_connection(db_config) cursor = connect.cursor() infos = None try: sql = "select lodo_id, username, level, exp from user order by level desc, exp desc limit 100" infos = cursor.fetchall(sql) infos = infos.to_list() finally: cursor.close() stat_user_level_rank = StatUserLevelRank() stat_user_level_rank.server_id = server.server_id stat_user_level_rank.data = json.dumps(infos) stat_user_level_rank.date = datetime.now().strftime("%Y-%m-%d") stat_user_level_rank.persist()
def get_user_level_rank_stat(server_id, date): return StatUserLevelRank.load(server_id=server_id, date=date)