dusql.py 669 B

123456789101112131415161718192021
  1. #!/usr/bin/python3
  2. import pymysql
  3. db = pymysql.connect(host="192.168.61.42", port=3306, user="eq",
  4. passwd="xdmy@1234", db="eq", charset="utf8")
  5. cursor = db.cursor()
  6. for sqlname in ["getChooseEqMonthBudgetListSumAll",
  7. "getChooseMonthWX",
  8. "getChooseElectricityPrice",
  9. "getChooseWaterPrice",
  10. "getChooseMonthiolPrice",
  11. "getChooseMonthOilT",
  12. "getChooseMonthElectricity",
  13. "getChooseMonthWater"
  14. ]:
  15. print(sqlname)
  16. sqlstr = open("%s.sql" % (sqlname), "r", encoding="utf-8").read()
  17. sql = "update apisql set sqlstr =%s where sqlname =%s"
  18. err = cursor.execute(sql, (sqlstr, sqlname))
  19. db.commit()
  20. db.close()