# -*- coding: utf-8 -*- """查询商品行与 sku 的数据库原始值,确认 PHP 侧的类型转换""" 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() pwds = re.findall(r'password:\s*"?([^"\n]+)"?', text) pwd = pwds[0].strip() conn = pymysql.connect(host="192.168.1.177", port=3306, user="root", password=pwd, database="shop") cur = conn.cursor() cur.execute("SELECT delivery_type, alone_grade_equity, points_discount_config, is_ind_delivery_type FROM yoshop_goods WHERE goods_id=10010") print("goods row:", cur.fetchone()) cur.execute("SELECT LEFT(content, 120) FROM yoshop_goods WHERE goods_id=10010") print("content head:", cur.fetchone()) cur.execute("SHOW COLUMNS FROM yoshop_goods_sku") print("sku cols:", [(r[0], r[1]) for r in cur.fetchall()]) cur.execute("SHOW TABLES LIKE '%service_rel%'") print("service rel:", cur.fetchall()) cur.execute("SHOW TABLES LIKE '%category_rel%'") print("category rel:", cur.fetchall()) conn.close()