feat: 根目录文档、脚本、gitignore
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""补:200 → 161/zentao_dev_2026,用户需求 2461 的 zt_action(objectType='user-story')。"""
|
||||
import io, sys, time, 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, autocommit=False)
|
||||
USID = 2461
|
||||
|
||||
def log(m): print(f'[{time.strftime("%H:%M:%S")}] {m}', flush=True)
|
||||
|
||||
src = pymysql.connect(**SRC); scur = src.cursor()
|
||||
dst = pymysql.connect(**DST); dcur = dst.cursor()
|
||||
|
||||
scur.execute("SELECT * FROM zt_action WHERE objectType='user-story' AND objectID=%s ORDER BY id", (USID,))
|
||||
cols = [d[0] for d in scur.description]
|
||||
rows = scur.fetchall()
|
||||
log(f'200 上 user-story/2461 action: {len(rows)} 行')
|
||||
if rows:
|
||||
dcur.execute("SELECT COUNT(*) FROM zt_action WHERE objectType='user-story' AND objectID=%s", (USID,))
|
||||
if dcur.fetchone()[0]:
|
||||
log('目标库已有,中止'); sys.exit(1)
|
||||
col_sql = ','.join(f'`{c}`' for c in cols)
|
||||
ph = ','.join(['%s'] * len(cols))
|
||||
dcur.executemany(f'INSERT INTO zt_action ({col_sql}) VALUES ({ph})', rows)
|
||||
dst.commit()
|
||||
log(f'插入 {len(rows)} 行')
|
||||
dcur.execute("SELECT id, action, actor, date FROM zt_action WHERE objectType='user-story' AND objectID=%s ORDER BY id", (USID,))
|
||||
for r in dcur.fetchall():
|
||||
log(f' {r}')
|
||||
src.close(); dst.close()
|
||||
Reference in New Issue
Block a user