You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.7 KiB
49 lines
1.7 KiB
import time,threading
|
|
#password填自己mysql的密码
|
|
import pymysql,outsideData,newsData,insideSummary,outsideSummary,insideData
|
|
con=pymysql.connect(host='localhost',passwd='123456',charset='utf8',user='root',db='cov2019_data')
|
|
cursor=con.cursor()
|
|
|
|
#多线程方案
|
|
# th=[]
|
|
|
|
# thread_insideData = threading.Thread(target=insideData.mysqlStart, args=(con, ))
|
|
# th.append(thread_insideData)
|
|
|
|
# thread_outsideData = threading.Thread(target=outsideData.mysqlStart, args=(con, ))
|
|
# th.append(thread_outsideData)
|
|
|
|
# thread_insideSummary = threading.Thread(target=insideSummary.mysqlStart, args=(con, ))
|
|
# th.append(thread_insideSummary)
|
|
|
|
# thread_outsideSummary = threading.Thread(target=outsideSummary.mysqlStart, args=(con, ))
|
|
# th.append(thread_outsideSummary)
|
|
|
|
# thread_news=threading.Thread(target=newsData.mysqlStart,args=(con,))
|
|
# th.append(thread_news)
|
|
#多线程方案启动
|
|
# while True:
|
|
# for t in th:
|
|
# t.run()
|
|
# for t in th:
|
|
# t.join()
|
|
|
|
#单一线程方案
|
|
def collect(con):
|
|
while True:
|
|
newsData.mysqlStart(con)
|
|
insideData.mysqlStart(con)
|
|
outsideData.mysqlStart(con)
|
|
insideSummary.mysqlStart(con)
|
|
outsideSummary.mysqlStart(con)
|
|
print("***********************每隔一小时自动更新数据***********************")
|
|
print("****************************此次更新完毕***************************")
|
|
updatetime=time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(time.time()+3600))
|
|
print("****************下一次启动时间: %s****************"%updatetime)
|
|
time.sleep(60*60)
|
|
#单一线程方案启动
|
|
t=threading.Thread(target=collect,args=(con,))
|
|
t.start()
|
|
t.join()
|
|
cursor.close()
|
|
con.close() |