loadsql.py 470 B

123456789101112131415
  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. sqlname = input("请输入sqlname:")
  7. cursor = db.cursor()
  8. err = cursor.execute("select sqlstr from apisql where sqlname =%s", sqlname)
  9. sqlstr = cursor.fetchone()
  10. write_file = open("%s.sql" % (sqlname), "w",
  11. encoding="utf-8").write(sqlstr[0])
  12. db.close()