login works backend
This commit is contained in:
@@ -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")
|
||||
Reference in New Issue
Block a user