diff --git a/app/core/config.py b/app/core/config.py index 57db8eb..75704aa 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -1,16 +1,19 @@ from pydantic_settings import BaseSettings from pathlib import Path -from typing import Optional +from typing import Optional, ClassVar + + +# Create DB directory outside of the Settings class +DB_DIR = Path("/projects/taskmanagerapi-8e2xek/app/storage/db") +DB_DIR.mkdir(parents=True, exist_ok=True) class Settings(BaseSettings): API_V1_STR: str = "/api/v1" PROJECT_NAME: str = "Task Manager API" - + # Database settings - DB_DIR = Path("/app") / "storage" / "db" - DB_DIR.mkdir(parents=True, exist_ok=True) DATABASE_URL: str = f"sqlite:///{DB_DIR}/db.sqlite" - + settings = Settings() \ No newline at end of file diff --git a/app/db/session.py b/app/db/session.py index 5c4108d..312f935 100644 --- a/app/db/session.py +++ b/app/db/session.py @@ -1,14 +1,8 @@ from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker -from pathlib import Path -import os +from app.core.config import settings -# Use relative path for development environment -BASE_DIR = Path(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) -DB_DIR = BASE_DIR / "app" / "storage" / "db" -DB_DIR.mkdir(parents=True, exist_ok=True) - -SQLALCHEMY_DATABASE_URL = f"sqlite:///{DB_DIR}/db.sqlite" +SQLALCHEMY_DATABASE_URL = settings.DATABASE_URL engine = create_engine( SQLALCHEMY_DATABASE_URL, diff --git a/start.py b/start.py new file mode 100644 index 0000000..24ea0f4 --- /dev/null +++ b/start.py @@ -0,0 +1,14 @@ +import os +import sys +from pathlib import Path + +# Add the project root to the Python path +BASE_DIR = Path(os.path.dirname(os.path.abspath(__file__))) +sys.path.insert(0, str(BASE_DIR)) + +# Import the app from main.py to check if it loads correctly +from main import app + +print("App loaded successfully!") +print(f"App name: {app.title}") +print("If you can see this message, the error has been fixed.") \ No newline at end of file