#!/usr/bin/python3 import pymysql db = pymysql.connect(host="222.73.129.15", port=31306, user="root", passwd="kepaiteng!QAZ", db="eq", charset="utf8") cursor = db.cursor() sqlname =input("请输入sqlname:") # sqlname ="update_device" sqlstr =open("%s.sql"%(sqlname),"r",encoding="utf-8").read() # print(sqlstr) sql ="update apisql set sqlstr =%s where sqlname =%s" err=cursor.execute(sql,(sqlstr,sqlname)) # err=cursor.execute(sqlstr) print(err) db.commit() db.close()