Skip to content

Commit

Permalink
fix: pydantic & sqlalchemy deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Oct 12, 2023
1 parent 9e441f8 commit 408441b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/backend/app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from functools import lru_cache
from typing import Any, Optional, Union

from pydantic import Extra, FieldValidationInfo, PostgresDsn, field_validator
from pydantic import FieldValidationInfo, PostgresDsn, field_validator
from pydantic_settings import BaseSettings, SettingsConfigDict


Expand Down Expand Up @@ -94,7 +94,7 @@ def assemble_db_connection(cls, v: Optional[str], info: FieldValidationInfo) ->
path=info.data.get("FMTM_DB_NAME", ""),
)
# Convert Url type to string
return str(pg_url)
return pg_url

ODK_CENTRAL_URL: Optional[str] = ""
ODK_CENTRAL_USER: Optional[str] = ""
Expand All @@ -111,7 +111,7 @@ def assemble_db_connection(cls, v: Optional[str], info: FieldValidationInfo) ->
SENTRY_DSN: Optional[str] = None

model_config = SettingsConfigDict(
case_sensitive=True, env_file=".env", extra=Extra.allow
case_sensitive=True, env_file=".env", extra="allow"
)


Expand All @@ -120,7 +120,7 @@ def get_settings():
"""Cache settings when accessed throughout app."""
_settings = Settings()
if _settings.DEBUG:
print(f"Loaded settings: {_settings.dict()}")
print(f"Loaded settings: {_settings.model_dump()}")
return _settings


Expand Down
5 changes: 2 additions & 3 deletions src/backend/app/db/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@
"""Config for the FMTM database connection."""

from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from sqlalchemy.orm import declarative_base, sessionmaker

from app.config import settings

engine = create_engine(settings.FMTM_DB_URL)
engine = create_engine(settings.FMTM_DB_URL.unicode_string())
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)

Base = declarative_base()
Expand Down

0 comments on commit 408441b

Please sign in to comment.