sql="select * from home_realtime_datas where updatedTime like '%s'"%(curdate+'%')
print('+++ sql: %s'%sql)
results1=[]
try:
self.cursor.execute(sql)
results1=self.cursor.fetchone()
n=1
whilelen(results1)<=0:
predate=self.get_pren_date(n)
sql="select * from home_realtime_datas where updatedTime like '%s'"%(predate+'%')
print('+++ presql: %s'%sql)
self.cursor.execute(sql)
results1=self.cursor.fetchone()
n+=1
ifn>=30:
break
else:
time.sleep(1)
exceptExceptionase:
print(e)
returnresults1
#获取国外疫情概况
defget_outside_realtime_datas(self):
curdate=self.get_cur_date()# 获取当天的日期
sql="select confirmedCount,currentConfirmedCount,confirmedIncr,curedCount,curedIncr,deadCount,deadIncr from outsidesummary_realtime_datas where updatedTime like '%s'"%(curdate+'%')
print('+++ sql: %s'%sql)
results=[]
try:
self.cursor.execute(sql)
results=self.cursor.fetchall()
n=1
whilelen(results)<=0:
predate=self.get_pren_date(n)
sql="select confirmedCount,currentConfirmedCount,confirmedIncr,curedCount,curedIncr,deadCount,deadIncr from outsidesummary_realtime_datas where updatedTime like '%s'"%(predate+'%')
print('+++ presql: %s'%sql)
self.cursor.execute(sql)
results=self.cursor.fetchall()
n+=1
ifn>=30:
break
else:
time.sleep(1)
exceptExceptionase:
print(e)
returnresults
#返回国内每日确诊人数(折线图用
defget_home_daily_datas(self):
sql="select curConfirm,updatedTime from home_realtime_datas"
print('+++ sql: %s'%sql)
results1=[]
results2=[]
try:
self.cursor.execute(sql)
results1=self.cursor.fetchall()
exceptExceptionase:
print(e)
foriinresults1:
results2.append((i[0],i[1][5:10]))
results2=tuple(results2)
returnresults2
# 国内各省份累计确诊病例数柱状图Top15
defget_province_confirmedCount_top15(self):
curdate=self.get_cur_date()# 获取当天的日期
sql="select provinceShortName,confirmedCount from province_daily_datas where pub_time like '%s' order by confirmedCount desc limit 15"%(curdate+'%')
print('+++ sql: %s'%sql)
results1=[]
try:
self.cursor.execute(sql)
results1=self.cursor.fetchall()
n=1
whilelen(results1)<=0:
predate=self.get_pren_date(n)
sql="select provinceShortName,confirmedCount from province_daily_datas where pub_time like '%s' order by confirmedCount desc limit 15"%(predate+'%')
print('+++ presql: %s'%sql)
self.cursor.execute(sql)
results1=self.cursor.fetchall()
n+=1
ifn>=30:
break
else:
time.sleep(1)
exceptExceptionase:
print(e)
returnresults1
#国内各省份现有确诊病例数(中国地图用No )
defget_province_currentConfirmedCount(self):
curdate=self.get_cur_date()# 获取当天的日期
sql="select provinceShortName,currentConfirmedCount,pub_time from province_daily_datas where pub_time like '%s' order by currentConfirmedCount"%(curdate+'%')
print('+++ sql: %s'%sql)
results1=[]
try:
self.cursor.execute(sql)
results1=list(self.cursor.fetchall())
n=1
whilelen(results1)<=0:
predate=self.get_pren_date(n)
sql="select provinceShortName,currentConfirmedCount,pub_time from province_daily_datas where pub_time like '%s' order by currentConfirmedCount"%(predate+'%')
print('+++ presql: %s'%sql)
self.cursor.execute(sql)
results1=list(self.cursor.fetchall())
n+=1
ifn>=30:
break
else:
time.sleep(1)
exceptExceptionase:
print(e)
returnresults1
#国内各省份现有确诊病例数饼图Top5
defget_province_currentConfirmedCount_top5(self):
curdate=self.get_cur_date()# 获取当天的日期
sql="select provinceShortName,currentConfirmedCount from province_daily_datas where pub_time like '%s' order by currentConfirmedCount desc limit 5"%(curdate+'%')
print('+++ sql: %s'%sql)
results1=[]
try:
self.cursor.execute(sql)
results1=list(self.cursor.fetchall())
n=1
f=False
whilelen(results1)<=0:
f=True
predate=self.get_pren_date(n)
sql="select provinceShortName,currentConfirmedCount from province_daily_datas where pub_time like '%s' order by currentConfirmedCount desc limit 5"%(predate+'%')
print('+++ presql: %s'%sql)
self.cursor.execute(sql)
results1=list(self.cursor.fetchall())
n+=1
ifn>=30:
break
else:
time.sleep(1)
print(f)
print(curdate)
if(f):
sql="select curConfirm from home_realtime_datas where updatedTime like '%s';"%(predate+'%')
else:
sql="select curConfirm from home_realtime_datas where updatedTime like '%s';"%(curdate+'%')
self.cursor.execute(sql)
results2=self.cursor.fetchone()
results1.append(("其他",results2[0]))
exceptExceptionase:
print(e)
results1=tuple(results1)
returnresults1
#获取省疫情信息
defget_province_daily_datas(self):
curdate=self.get_cur_date()# 获取当天的日期
sql="select * from province_daily_datas where pub_time like '%s'"%(curdate+'%')
print('+++ sql: %s'%sql)
results1=[]
try:
self.cursor.execute(sql)
results1=self.cursor.fetchall()
n=1
whilelen(results1)<=0:
predate=self.get_pren_date(n)
sql="select * from province_daily_datas where pub_time like '%s'"%(predate+'%')