tortoise / tortoise-orm

Familiar asyncio ORM for python, built with relations in mind
https://tortoise.github.io
Apache License 2.0
4.39k stars 357 forks source link

Enhancement for FastAPI lifespan support (#1371) #1540

Closed waketzheng closed 6 months ago

waketzheng commented 6 months ago

Description

Support register in fastapi's lifespan and leave register_tortoise there to compare old version

Motivation and Context

For some running projects, people may want to only upgrade dependencies without changing any code.

While for new project, it is more flexibility to use async with format to register db.

How Has This Been Tested?

make test
cd examples/fastapi && PYTHONPATH=. pytest _tests.py

Checklist: