"""
FreeFlow DB 상태 확인 스크립트
테이블 목록, 컬럼 정보, 레코드 수를 출력합니다.
"""
import mysql.connector

DB_CONFIG = {
    'host': 'officialsite.kr',
    'port': 23306,
    'user': 'admin',
    'password': 'dlgks~123',
    'database': 'freeflow',
}

def main():
    conn = mysql.connector.connect(**DB_CONFIG)
    cursor = conn.cursor()

    cursor.execute("SHOW TABLES")
    tables = cursor.fetchall()
    print(f"\n📋 Total tables: {len(tables)}\n")

    for (table_name,) in tables:
        cursor.execute(f"SELECT COUNT(*) FROM `{table_name}`")
        count = cursor.fetchone()[0]
        print(f"  📁 {table_name}: {count} rows")

        cursor.execute(f"DESCRIBE `{table_name}`")
        columns = cursor.fetchall()
        for col in columns:
            print(f"     - {col[0]} ({col[1]}) {'PK' if col[3] == 'PRI' else ''} {'NULL' if col[2] == 'YES' else 'NOT NULL'}")
        print()

    cursor.close()
    conn.close()

if __name__ == '__main__':
    main()
