a
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
from sqlalchemy import create_engine, text
|
||||
|
||||
engine = create_engine('sqlite:///cms.db')
|
||||
with engine.connect() as conn:
|
||||
print("=== home_experts 表数据 ===")
|
||||
rows = conn.execute(text("""
|
||||
SELECT he.id, he.post_id, he.sort_order, he.is_enabled,
|
||||
np.title AS old_post_title
|
||||
FROM home_experts he
|
||||
LEFT JOIN news_posts np ON np.id = he.post_id
|
||||
ORDER BY he.sort_order
|
||||
""")).fetchall()
|
||||
print(f"共 {len(rows)} 条记录")
|
||||
for r in rows:
|
||||
print(f" id={r[0]} post_id={r[1]} sort={r[2]} enabled={r[3]} title={r[4]}")
|
||||
|
||||
print("\n=== 用 title 匹配 articles 表 ===")
|
||||
for r in rows:
|
||||
if not r[4]:
|
||||
print(f" home_expert id={r[0]}: 老 post 已不存在")
|
||||
continue
|
||||
art = conn.execute(text("SELECT id, title FROM articles WHERE title = :t"), {"t": r[4]}).fetchone()
|
||||
if art:
|
||||
print(f" home_expert id={r[0]}: 老post_id={r[1]} -> 新article_id={art[0]} ({art[1]})")
|
||||
else:
|
||||
print(f" home_expert id={r[0]}: 老post_id={r[1]} 找不到对应的新 article (title={r[4]})")
|
||||
|
||||
print("\n=== home_modules 表结构 ===")
|
||||
cols = conn.execute(text("PRAGMA table_info(home_modules)")).fetchall()
|
||||
for c in cols:
|
||||
print(f" {c[1]} {c[2]}")
|
||||
print("\n=== home_modules 所有记录 ===")
|
||||
rows = conn.execute(text("SELECT * FROM home_modules")).fetchall()
|
||||
for r in rows:
|
||||
print(f" {r}"[:300])
|
||||
Reference in New Issue
Block a user