#!/usr/bin/env python3 """ 데이터베이스 로드 상태 검증 """ import sqlite3 from pathlib import Path def verify_databases(): """두 데이터베이스의 상태 확인""" kis_db = Path('src/quant_engine/kis_data_collection.db') snapshot_db = Path('src/quant_engine/snapshot_admin.db') print("="*80) print("데이터베이스 로드 상태 검증") print("="*80) for db_name, db_path in [("kis_data_collection", kis_db), ("snapshot_admin", snapshot_db)]: print(f"\n[{db_name}]") if not db_path.exists(): print(f" 파일 없음") continue conn = sqlite3.connect(db_path) cursor = conn.cursor() # 테이블 목록 cursor.execute("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name") tables = [row[0] for row in cursor.fetchall()] print(f" 테이블 수: {len(tables)}") print(f" 테이블: {', '.join(tables[:5])}..." if len(tables) > 5 else f" 테이블: {', '.join(tables)}") # 각 테이블의 행 수 print(f"\n 테이블별 행 수:") total_rows = 0 for table in sorted(tables): try: cursor.execute(f"SELECT COUNT(*) FROM {table}") count = cursor.fetchone()[0] if count > 0: print(f" {table}: {count:,}") total_rows += count except: pass print(f" 총 행 수: {total_rows:,}") conn.close() print("\n[완료]") if __name__ == "__main__": verify_databases()