"""
檢查租戶的 keycloak_realm
"""
import psycopg2

conn = psycopg2.connect(
    host="10.1.0.20",
    port=5433,
    database="hr_portal",
    user="admin",
    password="DC1qaz2wsx"
)
cur = conn.cursor()

cur.execute("""
    SELECT id, code, name, keycloak_realm, is_active
    FROM tenants;
""")

tenants = cur.fetchall()

print("=== Tenants Keycloak Realm ===\n")

for t in tenants:
    print(f"ID: {t[0]}")
    print(f"Code: {t[1]}")
    print(f"Name: {t[2]}")
    print(f"Keycloak Realm: {t[3]}")
    print(f"Is Active: {t[4]}")
    print("-" * 50)

cur.close()
conn.close()
