Skip to content
Snippets Groups Projects
Verified Commit 6a627d32 authored by Daniel Göbel's avatar Daniel Göbel
Browse files

Use the database URI from the settings in alembic

#10
parent 44dc1d27
No related branches found
No related tags found
No related merge requests found
import asyncio
import os
from logging.config import fileConfig
from pydantic import AnyUrl
from sqlalchemy import engine_from_config, pool
from sqlalchemy.ext.asyncio import AsyncEngine
from alembic import context
from app.core.config import settings
from app.db.base import Base
# this is the Alembic Config object, which provides
......@@ -30,16 +29,7 @@ target_metadata = Base.metadata
def get_url() -> str:
return str(
AnyUrl.build(
scheme="mysql+aiomysql",
password=os.getenv("DB_PASSWORD", ""),
user=os.getenv("DB_USER", ""),
port=os.getenv("DB_PORT", "3306"),
host=os.getenv("DB_HOST", "localhost"),
path=f"/{os.getenv('DB_DATABASE', '')}",
)
)
return str(settings.SQLALCHEMY_DATABASE_ASYNC_URI)
def run_migrations_offline():
......
......@@ -16,7 +16,7 @@ async def health_check(db: AsyncSession = Depends(get_db)) -> dict[str, str]:
except Exception:
raise HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail="Connection to database lost")
try:
httpx.get(settings.OBJECT_GATEWAY_URI, timeout=5.0)
httpx.get(settings.OBJECT_GATEWAY_URI, timeout=3.5)
except Exception:
raise HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail="Connection to RGW lost")
return {"status": "OK"}
......
......@@ -5,7 +5,7 @@ from fastapi.middleware.gzip import GZipMiddleware
from starlette.middleware.sessions import SessionMiddleware
from app.api.api import api_router
from app.api.miscellaneous_endpints import miscellaneous_router
from app.api.miscellaneous_endpoints import miscellaneous_router
from app.core.config import settings
description = """
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment