Exemple #1
0
def get_projects():
    # 获取项目信息并生成字典
    sqli = 'SELECT * FROM `projects`'
    result = sql_query(sqli)
    projects = {}
    for item in result:
        projects[item[1]] = item[0]
    return projects
Exemple #2
0
def china_map():
    sql = '''
    SELECT provience, SUM( confirm ) FROM provience_day_list 
    WHERE update_time =( SELECT update_time FROM provience_day_list 
    ORDER BY update_time DESC LIMIT 1 ) GROUP BY provience
    '''
    china_map_data = []
    res = sql_query(sql)
    for tup in res:
        china_map_data.append({"name": tup[0], "value": int(tup[1])})
    return render_template('map.html', china_map_data=china_map_data)
Exemple #3
0
def china_trend():
    """
    全国疫情趋势。
    :return:
    """
    data = []
    # “全国疫情新增趋势”数据:每日新增确诊,新增疑似
    add_new = []
    # “全国确诊(累计确诊,现有确诊)/现有疑似/现有重症”
    con_sus_serv = []
    # “全国累计治愈/死亡”
    dead_heal = []
    # “治愈率死亡率”
    dead_heal_rate = []

    sql = '''
        SELECT ds, add_confirm, add_suspect,
        confirm,now_confirm, suspect, now_severe,
        dead, heal,dead_rate, heal_rate
        FROM china_day_list china_day_list ORDER BY  ds ASC
    '''
    for ds, add_confirm, add_suspect, confirm, now_confirm, suspect, now_severe, dead, heal, dead_rate, heal_rate \
            in sql_query(sql):
        add_new.append({
            'ds': ds.strftime('%m-%d'),
            'add_confirm': add_confirm,
            'add_suspect': add_suspect
        })
        con_sus_serv.append({
            'ds': ds.strftime('%m-%d'),
            'confirm': confirm,
            'now_confirm': now_confirm,
            'suspect': suspect,
            'now_severe': now_severe
        })
        dead_heal.append({
            'ds': ds.strftime('%m-%d'),
            'heal': heal,
            'dead': dead
        })
        dead_heal_rate.append({
            'ds': ds.strftime('%m-%d'),
            'heal_rate': heal_rate,
            'dead_rate': dead_rate
        })
    data = [add_new, con_sus_serv, dead_heal, dead_heal_rate]
    print(data)
    return render_template('chinaTrend.html', data=data)
Exemple #4
0
def index():
    sql = '''
           SELECT ds, confirm, heal, dead, now_confirm, now_severe, imported_case FROM china_day_list
           ORDER BY ds DESC limit 1;
       '''
    res = sql_query(sql)[0]

    data = {
        'ds': res[0],
        'confirm': res[1],
        'heal': res[2],
        'dead': res[3],
        'now_confirm': res[4],
        'now_severe': res[5],
        'imported_case': res[6],
    }

    return render_template('index.html', data=data)
Exemple #5
0
                          enddate.strftime('%Y-%m-%d'), 'month', 'amount')
     # 更新统计日期
     set_option("arrange_amount_statdate",
                statdate_item.strftime('%Y-%m-%d'))
 # 关闭浏览器
 close_browser(browser)
 # 更新区域
 cities = json.loads(get_option("cities"))
 current_cities = []
 for cts in cities:
     current_scopes = cts['children']
     scopes = [item['value'] for item in current_scopes]
     addition_scopes = []
     sqli = 'SELECT DISTINCT `scope` FROM `dataset_resume` WHERE `city`="%s"' % cts[
         'value']
     result = sql_query(sqli)
     for item in result:
         if item[0] not in scopes:
             addition_scopes.append({
                 "value": item[0],
                 "label": item[0],
                 "center": {
                     "lng": 0,
                     "lng": 0
                 },
                 "zoom": 0
             })
     current_scopes.extend(addition_scopes)
     sorted_scopes = sorted(
         current_scopes, key=lambda current_scopes: current_scopes['value'])
     cts['children'] = sorted_scopes