#!/usr/bin/python3 import pymysql db = pymysql.connect(host="192.168.61.42", port=3306, user="eq", passwd="xdmy@1234", db="eq", charset="utf8") cursor = db.cursor() for sqlname in ["getChooseEqMonthBudgetListSumAll", "getChooseMonthWX", "getChooseElectricityPrice", "getChooseWaterPrice", "getChooseMonthiolPrice", "getChooseMonthOilT", "getChooseMonthElectricity", "getChooseMonthWater" ]: print(sqlname) sqlstr = open("%s.sql" % (sqlname), "r", encoding="utf-8").read() sql = "update apisql set sqlstr =%s where sqlname =%s" err = cursor.execute(sql, (sqlstr, sqlname)) db.commit() db.close()