import psycopg

conn = psycopg.connect(
    host='192.168.0.61',
    port=55432,
    dbname='njts_acct',
    user='njts_app',
    password='njts_app2025'
)

cur = conn.cursor()
cur.execute("""
    SELECT employee_id, employee_code, name, 
           photo_url IS NOT NULL as has_photo, 
           CASE WHEN photo_url IS NOT NULL THEN LENGTH(photo_url) ELSE 0 END as photo_length,
           CASE WHEN photo_url IS NOT NULL THEN SUBSTRING(photo_url, 1, 50) ELSE NULL END as photo_preview
    FROM employees 
    WHERE employee_code IN ('20190001', '20190002')
    ORDER BY employee_code
""")

rows = cur.fetchall()
print('従業員の写真データ状況:')
print('-' * 80)
for r in rows:
    print(f'ID: {r[0]}, Code: {r[1]}, Name: {r[2]}')
    print(f'  Has Photo: {r[3]}, Photo Length: {r[4]}')
    if r[5]:
        print(f'  Photo Preview: {r[5]}...')
    print()

cur.close()
conn.close()
