# -*- coding: utf-8 -*- """查看登录相关表结构""" import re import pymysql from pathlib import Path from _root import ROOT yml = Path(str(ROOT / "yoshop-java/src/main/resources/application.yml")) text = yml.read_text(encoding="utf-8") pwds = re.findall(r"password:\s*(.+)", text) pwd = pwds[0].strip().strip('"\'') conn = pymysql.connect(host="192.168.1.177", port=3306, user="root", password=pwd, database="shop") cur = conn.cursor() for t in ("yoshop_store_user", "yoshop_store", "yoshop_store_role"): print("=" * 20, t) cur.execute( "SELECT column_name, column_type, is_nullable, column_default FROM information_schema.columns " "WHERE table_schema='shop' AND table_name=%s ORDER BY ordinal_position", (t,)) for cn, ct, nl, df in cur.fetchall(): print(f" {cn:22s} {ct:20s} null={nl} default={df}") print("\n=== store_user 数据 ===") cur.execute("SELECT store_user_id, user_name, real_name, is_super, is_delete, store_id, LEFT(password,10) FROM yoshop_store_user") for r in cur.fetchall(): print(r) print("\n=== store 数据 ===") cur.execute("SELECT store_id, store_name, is_delete, is_recycle FROM yoshop_store") for r in cur.fetchall(): print(r) conn.close()