feat(db): add pool class configuration and adjust connection settings

This commit is contained in:
InfinityPacer
2024-10-20 03:10:08 +08:00
parent 08e07625cd
commit d1d98a9081
3 changed files with 38 additions and 28 deletions
+12 -10
View File
@@ -54,16 +54,18 @@ class ConfigModel(BaseModel):
DEV: bool = False
# 是否在控制台输出 SQL 语句,默认关闭
DB_ECHO: bool = False
# 是否在获取连接时进行预先 ping 操作,默认开启
DB_POOL_PRE_PING: bool = True
# 数据库连接池的大小,默认 100
DB_POOL_SIZE: int = 100
# 数据库连接的回收时间(秒),默认 3600 秒(1 小时)
DB_POOL_RECYCLE: int = 3600
# 数据库连接池获取连接的超时时间(秒),默认 180 秒
DB_POOL_TIMEOUT: int = 180
# 数据库连接池最大溢出连接数,默认 5
DB_MAX_OVERFLOW: int = 5
# 数据库连接池类型,QueuePool, NullPool
DB_POOL_TYPE: str = "QueuePool"
# 是否在获取连接时进行预先 ping 操作,默认关闭
DB_POOL_PRE_PING: bool = False
# 数据库连接池的大小,默认 20
DB_POOL_SIZE: int = 20
# 数据库连接的回收时间(秒),默认 1800
DB_POOL_RECYCLE: int = 1800
# 数据库连接池获取连接的超时时间(秒),默认 30 秒
DB_POOL_TIMEOUT: int = 30
# 数据库连接池最大溢出连接数,默认 10
DB_MAX_OVERFLOW: int = 10
# SQLite 的 busy_timeout 参数,默认为 60 秒
DB_TIMEOUT: int = 60
# 配置文件目录