initial commit

This commit is contained in:
2025-05-25 22:09:31 +02:00
commit e8b832addc
19 changed files with 1177 additions and 0 deletions

0
app/core/__init__.py Normal file
View File

10
app/core/config.py Normal file
View File

@@ -0,0 +1,10 @@
from pydantic_settings import BaseSettings
import os
class Settings(BaseSettings):
API_V1_STR: str = ""
PROJECT_NAME: str = "Choriosity Anmeldung"
SQLALCHEMY_DATABASE_URI: str = "sqlite:///" + os.environ.get("DATABASE_URL", "./db.sqlite")
settings = Settings()

19
app/core/db.py Normal file
View File

@@ -0,0 +1,19 @@
from sqlmodel import Session, create_engine
from app.core.config import settings
from app.models import Registration, RegistrationCreate
engine = create_engine(str(settings.SQLALCHEMY_DATABASE_URI))
# make sure all SQLModel models are imported (app.models) before initializing DB
# otherwise, SQLModel might fail to initialize relationships properly
# for more details: https://github.com/fastapi/full-stack-fastapi-template/issues/28
def init_db(session: Session) -> None:
# Tables should be created with Alembic migrations
# But if you don't want to use migrations, create
# the tables un-commenting the next lines
from sqlmodel import SQLModel
# This works because the models are already imported and registered from app.models
SQLModel.metadata.create_all(engine)