Hotfix + config optimization

- Fixed a bug that didn't let any function receive connection objects
- Added uvicorn logging level to config
This commit is contained in:
2025-09-06 01:09:30 +03:00
parent c2dd26c5d3
commit 16eccddb59
7 changed files with 29 additions and 30 deletions

View File

@ -1,6 +1,7 @@
import config
import router
import DBwork
from DBmodel import db
from fastapi import FastAPI
from loguru import logger
from contextlib import asynccontextmanager
@ -11,17 +12,14 @@ if config.enable_api_docs:
else:
docs_url = None
schema_name = config.schema_name
table_name = config.table_name
@asynccontextmanager
async def lifespan(app: FastAPI):
DBwork.set_connection()
DBwork.schema_creator(schema_name, DBwork.connection)
DBwork.table_creator(schema_name, table_name, DBwork.connection)
DBwork.schema_creator(config.schema_name, db.connection)
DBwork.table_creator(config.schema_name, config.table_name, db.connection)
yield
DBwork.close_connection(DBwork.connection)
DBwork.close_connection(db.connection)
app = FastAPI(docs_url=docs_url, lifespan=lifespan)