Spaces:
Paused
Paused
| import asyncio | |
| import logging | |
| import sys | |
| from app.db import verify_connection, init_db | |
| from app.core.config import settings | |
| import traceback | |
| # Configure logging to show all output | |
| logging.basicConfig( | |
| level=logging.DEBUG, | |
| format='%(asctime)s - %(levelname)s - %(message)s', | |
| handlers=[ | |
| logging.StreamHandler(sys.stdout) | |
| ] | |
| ) | |
| async def test_database(): | |
| print("=== Database Connection Test ===") | |
| print(f"Database URL: {settings.DATABASE_URL}") | |
| try: | |
| print("\nStep 1: Verifying basic connection...") | |
| await verify_connection() | |
| print("Basic connection successful!") | |
| print("\nStep 2: Initializing database...") | |
| await init_db() | |
| print("Database initialization successful!") | |
| print("\nAll tests passed successfully!") | |
| except Exception as e: | |
| print(f"\nError occurred: {str(e)}") | |
| print("\nFull traceback:") | |
| traceback.print_exc() | |
| sys.exit(1) | |
| if __name__ == "__main__": | |
| try: | |
| asyncio.run(test_database()) | |
| except KeyboardInterrupt: | |
| print("\nTest interrupted by user") | |
| except Exception as e: | |
| print(f"\nFatal error: {str(e)}") | |
| traceback.print_exc() | |
| sys.exit(1) |