dump_login_schema.py 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. # -*- coding: utf-8 -*-
  2. """查看登录相关表结构"""
  3. import re
  4. import pymysql
  5. from pathlib import Path
  6. yml = Path(r"C:\Users\Administrator\WorkBuddy\2026-10-17-12-27-10\java-rewrite\yoshop-java\src\main\resources\application.yml")
  7. text = yml.read_text(encoding="utf-8")
  8. pwds = re.findall(r"password:\s*(.+)", text)
  9. pwd = pwds[0].strip().strip('"\'')
  10. conn = pymysql.connect(host="192.168.1.177", port=3306, user="root", password=pwd, database="shop")
  11. cur = conn.cursor()
  12. for t in ("yoshop_store_user", "yoshop_store", "yoshop_store_role"):
  13. print("=" * 20, t)
  14. cur.execute(
  15. "SELECT column_name, column_type, is_nullable, column_default FROM information_schema.columns "
  16. "WHERE table_schema='shop' AND table_name=%s ORDER BY ordinal_position", (t,))
  17. for cn, ct, nl, df in cur.fetchall():
  18. print(f" {cn:22s} {ct:20s} null={nl} default={df}")
  19. print("\n=== store_user 数据 ===")
  20. cur.execute("SELECT store_user_id, user_name, real_name, is_super, is_delete, store_id, LEFT(password,10) FROM yoshop_store_user")
  21. for r in cur.fetchall():
  22. print(r)
  23. print("\n=== store 数据 ===")
  24. cur.execute("SELECT store_id, store_name, is_delete, is_recycle FROM yoshop_store")
  25. for r in cur.fetchall():
  26. print(r)
  27. conn.close()