from tortoise import Tortoise def init(app, generate_schemas: bool = False) -> None: @app.on_event("startup") async def __init(): # TODO: Поддержка других БД await Tortoise.init( db_url='sqlite://data.sqlite3', modules={'models': ['db.models.user']} ) if generate_schemas: await Tortoise.generate_schemas(safe=True) @app.on_event("shutdown") async def __close(): await Tortoise.close_connections()