File tree Expand file tree Collapse file tree 4 files changed +23
-9
lines changed
Expand file tree Collapse file tree 4 files changed +23
-9
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ class Settings(BaseSettings):
2020 token : str = Field (deafult = "token" , exclude = True )
2121 db_client_type : str = "mysql"
2222 db_url : str = Field (deafult = "" , exclude = True )
23+ use_db_pool : bool = True
2324 origin : str = ""
2425 cdn : str = ""
2526
Original file line number Diff line number Diff line change 1- FROM python:3.12 -slim
1+ FROM python:3.13 -slim
22
33COPY requirements.docker.txt requirements.txt
44RUN python3 -m pip install -r requirements.txt
Original file line number Diff line number Diff line change 1- fastapi == 0.111.0
2- mysql-connector-python == 9.0.0
3- pydantic == 2.8.2
4- pydantic-settings == 2.3.4
5- requests == 2.32.3
6- SQLAlchemy == 2.0.31
1+ fastapi == 0.116.1
2+ fastapi-cli == 0.0.8
3+ mysql-connector-python == 9.4.0
4+ pydantic == 2.11.7
5+ pydantic-settings == 2.10.1
6+ pydantic_core == 2.33.2
7+ requests == 2.32.4
8+ SQLAlchemy == 2.0.41
Original file line number Diff line number Diff line change 33
44from fastapi import status
55from fastapi .responses import JSONResponse
6- from sqlalchemy import create_engine , func
6+ from sqlalchemy import NullPool , create_engine , func
77from sqlalchemy .orm import sessionmaker
88
99from config import WB_URL_PREFIX , settings
@@ -25,7 +25,18 @@ class MysqlClient(DBClientBase):
2525
2626 @classmethod
2727 def init_db_client (cls ):
28- engine = create_engine (settings .db_url , pool_size = 100 , pool_recycle = 3600 )
28+ # do not use db pool
29+ if settings .use_db_pool :
30+ engine = create_engine (
31+ settings .db_url ,
32+ pool_size = 100 ,
33+ pool_recycle = 3600
34+ )
35+ else :
36+ engine = create_engine (
37+ settings .db_url ,
38+ poolclass = NullPool
39+ )
2940 cls .DBSession = sessionmaker (bind = engine )
3041
3142 @classmethod
You can’t perform that action at this time.
0 commit comments