matching / test_db_connection.py
Calcifer0323's picture
Fix: Update to RoSBERTa model (1024 dims), remove half precision, increase timeout
93cd57d
"""
Тестовый скрипт для проверки подключения к БД
"""
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}")