Files
pod_trend_agent/db/create_db.py
T
3218485270 d68cc3b9e3 v106-v109 童装支持 + 标题模板外部化 + 模板导出增强
- 新增男童/女童检测(gender_from_category 优先判童装)与童装场景图生成
  (configs/kids_features.yaml:模特/场景/服装风格,同一商品固定同一组)
- 童装 SPU 字段映射:kids_type→SPU商品属性-类型、kids_age→适用年龄段、
  target_audience 按性别映射、kids_type_map 女童「上衣」→「针织上衣」
- 标题生成提示词外部化:prompts/title_prompt_{1,2,3}.md + config.yaml 路由表
- 模板多站点匹配:经营站点可配多个,命中任意一个即匹配
- 种草图生成失败自动重试(seed_shot.retries,换场景/模特/风格)
- 模板导出新增 Preview 文件夹(成功产品 _composite.oss.jpg + result.xlsx)
- 修复 SKU 尺码未按从小到大排序(_size_rank 支持单一年龄码 6Y/10Y)
2026-09-01 17:24:23 +08:00

110 lines
3.3 KiB
Python

# -*- coding: utf-8 -*-
import sqlite3
db_path = r"C:\Users\Admin\Desktop\test模版\design_agent\pod_trend_agent\db\spu_sku.db"
conn = sqlite3.connect(db_path)
cur = conn.cursor()
# 若表已存在则先删除(重建表结构)
cur.execute("DROP TABLE IF EXISTS SKU")
cur.execute("DROP TABLE IF EXISTS SPU")
# ---------- SPU 表 ----------
cur.execute("""
CREATE TABLE SPU (
id INTEGER PRIMARY KEY AUTOINCREMENT,
code TEXT,
material TEXT,
component_1 TEXT,
component_2 TEXT,
component_3 TEXT,
component_proportion_1 TEXT,
component_proportion_2 TEXT,
component_proportion_3 TEXT,
pattern TEXT,
details TEXT,
collar_style TEXT,
style TEXT,
care_Instructions TEXT,
fabric TEXT,
target_audience TEXT,
season TEXT,
is_transparent TEXT,
layout TEXT,
weaving_method TEXT,
printing_type TEXT,
fabric_texture_1 TEXT,
fabric_weight_1 TEXT,
fabric_weight_unit_1 TEXT,
lining_texture TEXT,
country TEXT,
mark TEXT,
placket_type TEXT DEFAULT '套头衫',
sleeve_type TEXT DEFAULT '常规袖/直筒袖',
sleeve_length_type TEXT DEFAULT '短袖',
breast_pad TEXT DEFAULT '否',
silhouette TEXT DEFAULT 'H',
length_type TEXT DEFAULT '常规款',
belt TEXT DEFAULT '否',
occasion TEXT DEFAULT '休闲外出',
scene TEXT DEFAULT '休闲',
hemline_shape TEXT DEFAULT '伞状',
kids_type TEXT,
kids_age TEXT
)
""")
# ---------- SKU 表 ----------
cur.execute("""
CREATE TABLE SKU (
id INTEGER PRIMARY KEY AUTOINCREMENT,
spu_id INTEGER NOT NULL,
code TEXT,
price REAL,
color TEXT,
size TEXT,
size_group TEXT,
size_type TEXT,
shoulder_width TEXT,
bust TEXT,
clothing_length TEXT,
sleeve_length TEXT,
longest_side TEXT,
secondary_long_side TEXT,
shortest_side TEXT,
package_weight TEXT,
img_url_2 TEXT,
img_url_3 TEXT,
img_url_4 TEXT,
img_url_5 TEXT,
FOREIGN KEY (spu_id) REFERENCES SPU(id)
)
""")
# 索引:SKU 按 spu_id 快速查询
cur.execute("CREATE INDEX idx_sku_spu_id ON SKU(spu_id)")
conn.commit()
# ---------- 验证 ----------
cur.execute("SELECT name FROM sqlite_master WHERE type='table'")
tables = cur.fetchall()
print("数据库文件:", db_path)
print("表列表:", [t[0] for t in tables])
cur.execute("PRAGMA table_info(SPU)")
spu_cols = cur.fetchall()
print("\nSPU 字段 ({}个):".format(len(spu_cols)))
for row in spu_cols:
print(" ", row[1], "|", row[2], "| 主键" if row[5] else "")
cur.execute("PRAGMA table_info(SKU)")
sku_cols = cur.fetchall()
print("\nSKU 字段 ({}个):".format(len(sku_cols)))
for row in sku_cols:
print(" ", row[1], "|", row[2], "| 主键" if row[5] else "")
conn.close()
print("\n创建完成")