"""Check users table — all 4 fields (username, phone, password_hash, token).""" import sys sys.path.insert(0, r"D:\传奇\cq2_sdk\src") from cq2_sdk.env_loader import load_env load_env(r"D:\传奇\cq2_sdk\.env") from cq2_sdk.store import UserStore, connection with connection() as conn: with conn.cursor() as cur: cur.execute( "SELECT id, username, phone, " "IFNULL(password_hash, '') AS pwd, " "IFNULL(LEFT(token, 30), '') AS tok, " "last_login_at " "FROM users ORDER BY id" ) rows = cur.fetchall() print(f"--- users in MySQL ({len(rows)} total) ---") if not rows: print(" (empty table -- A1 has NEVER been run)") for r in rows: # cursorclass=DictCursor in get_connection, so r is a dict print( f" id={r['id']:>2} " f"username={r['username']!r:<25} " f"phone={r['phone']!r:<15} " f"password_hash={r['pwd']!r:<18} " f"token={r['tok']!r:<35} " f"last_login={r['last_login_at']}" ) # Specifically check longwu988 u = UserStore(conn).get_by_username("longwu988") print() if u is None: print("==> ANSWER: longwu988 NOT in DB. A1 has NOT been run successfully.") elif not u.token: print(f"==> ANSWER: longwu988 exists (id={u.id}) but has NO token. A1 partially ran (failed before saving).") else: print( f"==> ANSWER: A1 row exists. longwu988 id={u.id}, " f"password_hash={u.password_hash!r}, " f"token={u.token[:24]}..., last_login={u.last_login_at}" )