mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-08 01:06:59 +08:00
refactor: Increase database connection pool
This commit is contained in:
@@ -92,5 +92,10 @@ class Settings(BaseSettings):
|
||||
EMBEDDING_SIMILARITY: float = 0.4
|
||||
EMBEDDING_TOP_COUNT: int = 5
|
||||
|
||||
PG_POOL_SIZE: int = 20
|
||||
PG_MAX_OVERFLOW: int = 30
|
||||
PG_POOL_RECYCLE: int = 3600
|
||||
PG_POOL_PRE_PING: bool = True
|
||||
|
||||
|
||||
settings = Settings() # type: ignore
|
||||
|
||||
@@ -2,8 +2,11 @@ from sqlmodel import Session, create_engine, SQLModel
|
||||
|
||||
from common.core.config import settings
|
||||
|
||||
engine = create_engine(str(settings.SQLALCHEMY_DATABASE_URI), pool_size=20, max_overflow=30, pool_recycle=3600,
|
||||
pool_pre_ping=True)
|
||||
engine = create_engine(str(settings.SQLALCHEMY_DATABASE_URI),
|
||||
pool_size=settings.PG_POOL_SIZE,
|
||||
max_overflow=settings.PG_MAX_OVERFLOW,
|
||||
pool_recycle=settings.PG_POOL_RECYCLE,
|
||||
pool_pre_ping=settings.PG_POOL_PRE_PING)
|
||||
|
||||
|
||||
def get_session():
|
||||
|
||||
Reference in New Issue
Block a user