| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- import pymysql
- print('检查疑似错误标注为空的成员...')
- try:
- conn = pymysql.connect(
- host='rm-f8ze60yirdj8786u2wo.mysql.rds.aliyuncs.com',
- port=3306,
- user='root',
- password='csqz@20255',
- db='csqz-client',
- charset='utf8mb4',
- cursorclass=pymysql.cursors.DictCursor
- )
- print('数据库连接成功')
-
- cursor = conn.cursor()
-
- # 查询所有suspected_error字段不为NULL但可能为空的成员
- query = """
- SELECT id, name, simplified_name, suspected_error
- FROM family_member_info
- WHERE suspected_error IS NOT NULL
- ORDER BY name
- """
- cursor.execute(query)
- members = cursor.fetchall()
-
- print(f'\n找到 {len(members)} 个成员的suspected_error字段不为NULL')
- print('\n检查suspected_error字段值:')
- print('-' * 80)
-
- empty_count = 0
- for member in members:
- se = member['suspected_error']
- se_type = type(se)
- se_repr = repr(se)
- se_len = len(se) if isinstance(se, str) else 0
-
- if not se or se.strip() == '':
- empty_count += 1
- print(f'ID: {member["id"]}, 姓名: {member["name"]}, 疑似错误标注: {se_repr}, 类型: {se_type}, 长度: {se_len}')
-
- print('-' * 80)
- print(f'\n其中 {empty_count} 个成员的疑似错误标注为空')
-
- conn.close()
- except Exception as e:
- print(f'Error: {e}')
|