| 1234567891011121314151617181920212223 |
- # -*- coding: utf-8 -*-
- """读取 application.yml 的连接信息,导出三张商品相关表结构"""
- import re
- import pymysql
- from _root import ROOT
- YML = str(ROOT / "yoshop-java/src/main/resources/application.yml")
- text = open(YML, encoding="utf-8").read()
- pwd = re.findall(r"password:\s*(.+)", text)[0].strip().strip("\"'")
- conn = pymysql.connect(host="192.168.1.177", port=3306, user="root", password=pwd, database="shop")
- cur = conn.cursor()
- cur.execute(
- "SELECT table_name,column_name,column_type FROM information_schema.columns "
- "WHERE table_schema='shop' AND table_name IN ('yoshop_goods','yoshop_goods_image','yoshop_upload_file') "
- "ORDER BY table_name, ordinal_position")
- cur_t = None
- for tn, cn, ct in cur.fetchall():
- if tn != cur_t:
- print("--", tn)
- cur_t = tn
- print(f" {cn} {ct}")
- conn.close()
|