File size: 1,316 Bytes
363cda9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""
Run all database debug checks.

Run as follows:
>>> POSTGRES_HOST=localhost POSTGRES_PORT=5433 POSTGRES_PASSWORD=password123 python -m scripts.db.debug_all

This runs:
1. Connection test
2. Session query test
3. List existing candidates
"""

import sys
import os

# Add project root to sys.path
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))
if project_root not in sys.path:
    sys.path.insert(0, project_root)

from scripts.db.test_connection import test_connection
from scripts.db.test_session import test_session_query
from scripts.db.list_candidates import list_candidates


def run_all_checks() -> None:
    """Run all database diagnostic checks."""
    print("=" * 50)
    print("🔍 DATABASE DIAGNOSTICS")
    print("=" * 50)
    
    # 1. Test connection
    conn_ok = test_connection()
    
    if not conn_ok:
        print("\n⛔ Stopping - connection failed")
        return
    
    print()
    
    # 2. Test session
    session_ok = test_session_query()
    
    if not session_ok:
        print("\n⛔ Stopping - session failed")
        return
    
    print()
    
    # 3. List candidates
    list_candidates()
    
    print()
    print("=" * 50)
    print("✅ All checks completed")
    print("=" * 50)


if __name__ == "__main__":
    run_all_checks()