diff --git a/数据分析和可视化/新冠疫情/__pycache__/models.cpython-36.pyc b/数据分析和可视化/新冠疫情/__pycache__/models.cpython-36.pyc index fba0d12..2e4b59f 100644 Binary files a/数据分析和可视化/新冠疫情/__pycache__/models.cpython-36.pyc and b/数据分析和可视化/新冠疫情/__pycache__/models.cpython-36.pyc differ diff --git a/数据分析和可视化/新冠疫情/hello.py b/数据分析和可视化/新冠疫情/hello.py index aa360f7..3b09917 100644 --- a/数据分析和可视化/新冠疫情/hello.py +++ b/数据分析和可视化/新冠疫情/hello.py @@ -9,6 +9,7 @@ def query_province_topn(): db=GetFromDB() results=db.query_province_topn('2020-08-07',5) data=jsonify(pub_dates=str(results[0][2]),areas=[x[0] for x in results],curcofirms=[x[1] for x in results]) + return data @app.route("/chinaInfo/",methods=['POST']) @@ -25,7 +26,11 @@ def GlobalInfomation(): db = GetFromDB() results=db.searchForeignInformation('2020-08-10') #由于查询到的数据中没有中国的信息,因此需要查询中国的信息加到世界信息中 - data=jsonify(country=[x[3] for x in results], confirmed=[x[0] for x in results],died=[x[1] for x in results], + country = [x[3] for x in results] + country.append("中国") + confirmed = [x[0] for x in results] + confirmed.append(db.searchSummaryChina('2020-08-10')[0][1]) + data=jsonify(country=country, confirmed=confirmed,died=[x[1] for x in results], crued=[x[2] for x in results],curConfirm=[x[4] for x in results],confirmedRelative=[x[5] for x in results]) return data diff --git a/数据分析和可视化/新冠疫情/models.py b/数据分析和可视化/新冠疫情/models.py index 7767624..5b94994 100644 --- a/数据分析和可视化/新冠疫情/models.py +++ b/数据分析和可视化/新冠疫情/models.py @@ -42,6 +42,14 @@ class GetFromDB(): thedate = date + "%" sql='select confirmed,died,crued,country,curConfirm,confirmedRelative from ForeignCountry where pub_date like "%s"'%(thedate) self.cursor.execute(sql) + return self.cursor.fetchall() + + + #查询国内疫情概况 + def searchSummaryChina(self,date): + thedate = date + "%" + sql='select * from InsideChina where updateTime like "%s"'%(thedate) + self.cursor.execute(sql) + return self.cursor.fetchall() - return self.cursor.fetchall() \ No newline at end of file diff --git a/数据分析和可视化/新冠疫情/templates/global.html b/数据分析和可视化/新冠疫情/templates/global.html index 9ee445f..bc485d4 100644 --- a/数据分析和可视化/新冠疫情/templates/global.html +++ b/数据分析和可视化/新冠疫情/templates/global.html @@ -20,7 +20,7 @@ -