testdriven.io Test-Driven Development with FastAPI and Docker / why os.environ.get instead of using get_settings()?

115 views Asked by At

I am at https://testdriven.io/courses/tdd-fastapi/postgres-setup/#H-1-tortoise-orm right now.. and I see that os.environ.get("DATABASE_URL") is used in the register_tortoise call:

register_tortoise(
    app,
    db_url=os.environ.get("DATABASE_URL"),
    modules={"models": ["app.models.tortoise"]},
    generate_schemas=True,
    add_exception_handlers=True,
)

Has anybody wondered: why not make use of get_settings, since (a) it is already available (from app.config import get_settings, Settings), and (b) get_settings is already decorated with @lru_cache, so it is not a concern calling it?

0

There are 0 answers