Fred808 commited on
Commit
3e24ce6
·
verified ·
1 Parent(s): a9082d9

Update test_connection.py

Browse files
Files changed (1) hide show
  1. test_connection.py +43 -43
test_connection.py CHANGED
@@ -1,44 +1,44 @@
1
- import asyncio
2
- import logging
3
- import sys
4
- from app.db.database import verify_connection, init_db
5
- from app.core.config import settings
6
- import traceback
7
-
8
- # Configure logging to show all output
9
- logging.basicConfig(
10
- level=logging.DEBUG,
11
- format='%(asctime)s - %(levelname)s - %(message)s',
12
- handlers=[
13
- logging.StreamHandler(sys.stdout)
14
- ]
15
- )
16
-
17
- async def test_database():
18
- print("=== Database Connection Test ===")
19
- print(f"Database URL: {settings.DATABASE_URL}")
20
- try:
21
- print("\nStep 1: Verifying basic connection...")
22
- await verify_connection()
23
- print("Basic connection successful!")
24
-
25
- print("\nStep 2: Initializing database...")
26
- await init_db()
27
- print("Database initialization successful!")
28
-
29
- print("\nAll tests passed successfully!")
30
- except Exception as e:
31
- print(f"\nError occurred: {str(e)}")
32
- print("\nFull traceback:")
33
- traceback.print_exc()
34
- sys.exit(1)
35
-
36
- if __name__ == "__main__":
37
- try:
38
- asyncio.run(test_database())
39
- except KeyboardInterrupt:
40
- print("\nTest interrupted by user")
41
- except Exception as e:
42
- print(f"\nFatal error: {str(e)}")
43
- traceback.print_exc()
44
  sys.exit(1)
 
1
+ import asyncio
2
+ import logging
3
+ import sys
4
+ from app.db import verify_connection, init_db
5
+ from app.core.config import settings
6
+ import traceback
7
+
8
+ # Configure logging to show all output
9
+ logging.basicConfig(
10
+ level=logging.DEBUG,
11
+ format='%(asctime)s - %(levelname)s - %(message)s',
12
+ handlers=[
13
+ logging.StreamHandler(sys.stdout)
14
+ ]
15
+ )
16
+
17
+ async def test_database():
18
+ print("=== Database Connection Test ===")
19
+ print(f"Database URL: {settings.DATABASE_URL}")
20
+ try:
21
+ print("\nStep 1: Verifying basic connection...")
22
+ await verify_connection()
23
+ print("Basic connection successful!")
24
+
25
+ print("\nStep 2: Initializing database...")
26
+ await init_db()
27
+ print("Database initialization successful!")
28
+
29
+ print("\nAll tests passed successfully!")
30
+ except Exception as e:
31
+ print(f"\nError occurred: {str(e)}")
32
+ print("\nFull traceback:")
33
+ traceback.print_exc()
34
+ sys.exit(1)
35
+
36
+ if __name__ == "__main__":
37
+ try:
38
+ asyncio.run(test_database())
39
+ except KeyboardInterrupt:
40
+ print("\nTest interrupted by user")
41
+ except Exception as e:
42
+ print(f"\nFatal error: {str(e)}")
43
+ traceback.print_exc()
44
  sys.exit(1)