45 lines
1.9 KiB
Python
45 lines
1.9 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""只读勘察第四轮:其余自定义 story 关联表 + 正确重读 zt_story_expand。绝不写入。"""
|
|
import io, sys, pymysql
|
|
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
|
|
|
|
SRC = dict(host='192.168.3.200', user='root', password='PX4fTAAsJ#T!1',
|
|
database='zentao_dev', charset='utf8mb4', connect_timeout=15)
|
|
DST = dict(host='192.168.1.161', user='devgps', password='dev@2021GPS',
|
|
database='zentao_dev_2026', charset='utf8mb4', connect_timeout=15)
|
|
SID = 9197
|
|
|
|
src = pymysql.connect(**SRC); scur = src.cursor()
|
|
dst = pymysql.connect(**DST); dcur = dst.cursor()
|
|
|
|
def cols_of(cur, db, t):
|
|
cur.execute("""SELECT column_name FROM information_schema.columns
|
|
WHERE table_schema=%s AND table_name=%s ORDER BY ordinal_position""", (db, t))
|
|
return [r[0] for r in cur.fetchall()]
|
|
|
|
TABLES = ['zt_story_expand', 'zt_story_feedback', 'zt_story_user', 'zt_story_userspec',
|
|
'zt_story_case', 'zt_story_month_workload', 'zt_story_user_task']
|
|
|
|
for t in TABLES:
|
|
for label, cur, db in [('200', scur, 'zentao_dev'), ('161_2026', dcur, 'zentao_dev_2026')]:
|
|
cols = cols_of(cur, db, t)
|
|
if not cols:
|
|
print(f'{label} {t}: 不存在'); continue
|
|
keys = [c for c in cols if c in ('story_id', 'story', 'storyId')]
|
|
if not keys:
|
|
print(f'{label} {t}: 无 story 关联列, 列={cols[:8]}...'); continue
|
|
k = keys[0]
|
|
cur.execute(f"SELECT * FROM `{t}` WHERE `{k}`=%s", (SID,))
|
|
rows = cur.fetchall()
|
|
print(f'{label} {t}({k}=9197): {len(rows)} 行')
|
|
for r in rows:
|
|
d = dict(zip(cols, r))
|
|
# 长文本截断
|
|
for kk, vv in d.items():
|
|
if isinstance(vv, (bytes, str)) and len(str(vv)) > 60:
|
|
d[kk] = str(vv)[:60] + '...'
|
|
print(' ', d)
|
|
|
|
src.close(); dst.close()
|
|
print('done')
|