usql.py 457 B

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