File size: 1,984 Bytes
93cd57d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
"""
Тестовый скрипт для проверки подключения к БД
"""
try:
    import psycopg2
    print("✅ psycopg2 installed")
except ImportError:
    print("❌ psycopg2 not installed. Run: pip install psycopg2-binary")
    exit(1)

try:
    import bcrypt
    print("✅ bcrypt installed")
except ImportError:
    print("❌ bcrypt not installed. Run: pip install bcrypt")
    exit(1)

# Данные подключения
DB_CONFIG = {
    'host': 'dpg-d5ht8vi4d50c739akh2g-a.virginia-postgres.render.com',
    'port': 5432,
    'database': 'lead_exchange_bk',
    'user': 'lead_exchange_bk_user',
    'password': '8m2gtTRBW0iAr7nY2Aadzz0VcZBEVKYM'
}

print(f"\nConnecting to {DB_CONFIG['host']}...")

try:
    conn = psycopg2.connect(**DB_CONFIG)
    print("✅ Connected successfully!")

    cursor = conn.cursor()

    # Проверяем таблицы
    cursor.execute("""
        SELECT table_name
        FROM information_schema.tables
        WHERE table_schema = 'public'
        ORDER BY table_name
    """)

    tables = cursor.fetchall()
    print(f"\n📋 Tables in database:")
    for table in tables:
        print(f"  - {table[0]}")

    # Проверяем пользователей
    cursor.execute("SELECT COUNT(*) FROM users")
    user_count = cursor.fetchone()[0]
    print(f"\n👤 Users count: {user_count}")

    if user_count > 0:
        cursor.execute("SELECT email, role FROM users LIMIT 5")
        users = cursor.fetchall()
        print("  Sample users:")
        for email, role in users:
            print(f"    - {email} ({role})")

    # Проверяем properties
    cursor.execute("SELECT COUNT(*) FROM properties")
    prop_count = cursor.fetchone()[0]
    print(f"\n🏠 Properties count: {prop_count}")

    cursor.close()
    conn.close()

    print("\n✅ All checks passed!")

except psycopg2.Error as e:
    print(f"\n❌ Database error: {e}")
except Exception as e:
    print(f"\n❌ Error: {e}")