upsql.py 477 B

12345678910111213141516
  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. # sqlname ="update_device"
  7. sqlstr =open("%s.sql"%(sqlname),"r",encoding="utf-8").read()
  8. # print(sqlstr)
  9. sql ="update apisql set sqlstr =%s where sqlname =%s"
  10. err=cursor.execute(sql,(sqlstr,sqlname))
  11. # err=cursor.execute(sqlstr)
  12. print(err)
  13. db.commit()
  14. db.close()