#!/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:") try: 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)) print(err) db.commit() except: db.rollback() db.close()