upsql.py 411 B

123456789101112
  1. #!/usr/bin/python3
  2. import pymysql
  3. db = pymysql.connect(host="222.73.129.15", port=31306, user="root", passwd="kepaiteng!QAZ", db="eq", charset="utf8")
  4. cursor = db.cursor()
  5. sqlname =input("请输入sqlname:")
  6. sqlstr =open("../sql/%s.sql"%(sqlname),"r",encoding="utf-8").read()
  7. sql ="update apisql set sqlstr =%s where sqlname =%s"
  8. err=cursor.execute(sql,(sqlstr,sqlname))
  9. print(err)
  10. db.commit()
  11. db.rollback()