pyfsql.py 484 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", passwd="kepaiteng!QAZ", db="eq", charset="utf8")
  5. sqlname =input("请输入sqlname:")
  6. try:
  7. cursor = db.cursor()
  8. err =cursor.execute("select sqlstr from apisql where sqlname =%s",sqlname)
  9. sqlstr =cursor.fetchone()
  10. print(sqlstr[0])
  11. write_file = open("%s.sql"%(sqlname), "w", encoding="utf-8").write(sqlstr[0])
  12. except:
  13. print()
  14. db.close()