login works backend

This commit is contained in:
2026-01-20 01:33:55 +00:00
parent 797a696aff
commit accf35e364
3 changed files with 43 additions and 24 deletions

View File

@@ -19,13 +19,18 @@ mysql_pwd = os.environ.get("MYSQL_PASSWORD","")
@asynccontextmanager
async def lifespan(app: FastAPI):
if mode == "mysql":
pool = await aiomysql.create_pool(host=mysql_host,user=mysql_user,password=mysql_pwd,db=mysql_db_name, minsize=1, maxsize=10)
try:
print("Going with mysql")
global mysql_pool
mysql_pool = await aiomysql.create_pool(host=mysql_host,user=mysql_user,password=mysql_pwd,db=mysql_db_name, minsize=1, maxsize=10)
yield
finally:
pool.close()
await pool.wait_closed()
else:
mysql_pool.close()
await mysql_pool.wait_closed()
elif mode == "sqlite":
try:
print("Going with sqlite")
yield
finally: pass # no action required now
finally: pass # no action required now
else:
raise EnvironmentError("DB_MODE must either be mysql or sqlite")