Skip to content

Potential enhancements for book v2 (opinionated) #12

Open
@badlydrawnrob

Description

@badlydrawnrob

BUG: @app.on_event("startup") is deprecated, use lifespan= handlers instead
Code currently works but will very likely stop working in future FastApi versions

@app.on_event("startup")
def on_startup():
    conn()

@Youngestdev This is explained in the advanced documentation for lifespan events, and I understand the general idea (in that documentation) but it uses contextlib and seems a bit advanced Python, so a rough rewrite of chaper 06 when calling conn() function would be very helpful.

I'm assuming conn() has to run once, and once only before startup (to create the database), and that get_session() opens and closes the database for read/write automatically (for regular use).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions