#!/usr/bin/env python3
"""Check database status"""
import sqlite3
from pathlib import Path

db_path = Path("data/kpi_analysis.db")
conn = sqlite3.connect(db_path)
cursor = conn.cursor()

print("Database Status:")
print("=" * 50)

tables = ['users', 'kpi_files', 'kpi_analysis_results', 'kpi_data_cache', 'user_sessions', 'application_logs']

for table in tables:
    cursor.execute(f"SELECT COUNT(*) FROM {table}")
    count = cursor.fetchone()[0]
    status = "✅ Empty" if count == 0 else f"⚠️  {count} rows"
    print(f"{table:25} {status}")

conn.close()

print("=" * 50)
print("\nUploads directory:")
uploads = list(Path("uploads").glob("*"))
print(f"  Files: {len([f for f in uploads if f.is_file()])}")

print("\nReports directory:")
reports = list(Path("reports").glob("*"))
print(f"  Files: {len([f for f in reports if f.is_file()])}")
