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.
35 lines
995 B
35 lines
995 B
# python -m pip install --upgrade pip -i http://pypi.douban.com/simple/
|
|
# pip install pymysql -i http://pypi.douban.com/simple/
|
|
import datetime
|
|
import json
|
|
|
|
from MySQLHelper import MySQLHelper
|
|
|
|
|
|
# 黄海定义的输出信息的办法,带当前时间
|
|
def logInfo(msg):
|
|
i = datetime.datetime.now()
|
|
print(" %s %s" % (i, msg))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
with open("./pack.json", "r", encoding="utf-8") as f:
|
|
_dict = json.load(f)
|
|
|
|
#
|
|
allcnt = 0
|
|
db = MySQLHelper()
|
|
for _bean in _dict:
|
|
actions = _dict[_bean]
|
|
for action in actions:
|
|
memo = action["memo"]
|
|
sql = action["sql"]
|
|
while True:
|
|
cnt = db.execute(sql)
|
|
allcnt = allcnt + cnt
|
|
if cnt == 0:
|
|
break
|
|
logInfo(memo + ",更新%s条" % cnt)
|
|
db.close()
|
|
logInfo("恭喜,所有清洗工作成功完成,共清洗%s条" % allcnt)
|