You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
1.2 KiB
22 lines
1.2 KiB
|
15 hours ago
|
# -*- coding: utf-8 -*-
|
||
|
|
"""diag-arch.py — e2c-% 按 archive_status 分布 + 非 seed 明细(正确口径:1=有效 2=已归档)"""
|
||
|
|
import io, sys, json, pymysql
|
||
|
|
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
|
||
|
|
|
||
|
|
ids = json.load(open('.scratch/customer-e2e/seed-ids.json', encoding='utf-8'))
|
||
|
|
SEED = {str(v['id']) for v in ids.get('customers', {}).values()}
|
||
|
|
|
||
|
|
conn = pymysql.connect(host='8.129.84.155', port=3306, user='root', password='Itc@123456',
|
||
|
|
database='crm', charset='utf8mb4', autocommit=True,
|
||
|
|
connect_timeout=10, cursorclass=pymysql.cursors.DictCursor)
|
||
|
|
with conn.cursor() as cur:
|
||
|
|
cur.execute("SELECT archive_status a, COUNT(*) c FROM customer "
|
||
|
|
"WHERE customer_name LIKE 'e2c-%' GROUP BY archive_status")
|
||
|
|
print('分布:', {str(r['a']): r['c'] for r in cur.fetchall()})
|
||
|
|
cur.execute("SELECT id, customer_no, customer_name, archive_status, create_time FROM customer "
|
||
|
|
"WHERE customer_name LIKE 'e2c-%' ORDER BY create_time")
|
||
|
|
for r in cur.fetchall():
|
||
|
|
tag = 'seed' if str(r['id']) in SEED else '非seed'
|
||
|
|
if tag == '非seed':
|
||
|
|
print(f" [{tag}] {r['id']} {r['customer_name']} arch={r['archive_status']} {r['create_time']}")
|