Subir todos los cambios recientes a la rama principal
This commit is contained in:
18
backend/test_db_connection.py
Normal file
18
backend/test_db_connection.py
Normal file
@@ -0,0 +1,18 @@
|
||||
import os
|
||||
import asyncio
|
||||
import asyncpg
|
||||
|
||||
def get_database_url():
|
||||
# Replace 'postgresql+asyncpg' with 'postgresql' for asyncpg compatibility
|
||||
return os.getenv("DATABASE_URL", "postgresql://servicemanager:servicemanager123@servicemanager-db:5432/servicemanager").replace("postgresql+asyncpg", "postgresql")
|
||||
|
||||
async def test_connection():
|
||||
try:
|
||||
conn = await asyncpg.connect(get_database_url())
|
||||
print("Connection to the database was successful!")
|
||||
await conn.close()
|
||||
except Exception as e:
|
||||
print(f"Failed to connect to the database: {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(test_connection())
|
||||
Reference in New Issue
Block a user