基本结构以及计算降雨栅格
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
"""
|
||||
数据库配置
|
||||
"""
|
||||
from .base_config import BaseConfig
|
||||
|
||||
|
||||
class DatabaseConfig(BaseConfig):
|
||||
"""数据库配置类"""
|
||||
|
||||
# PostgreSQL配置
|
||||
DB_HOST: str = "localhost"
|
||||
DB_PORT: int = 5432
|
||||
DB_USER: str = "postgres"
|
||||
DB_PASSWORD: str = "postgres"
|
||||
DB_NAME: str = "test_db"
|
||||
|
||||
# 连接池配置
|
||||
DB_POOL_SIZE: int = 10
|
||||
DB_MAX_OVERFLOW: int = 20
|
||||
DB_POOL_TIMEOUT: int = 30
|
||||
DB_POOL_RECYCLE: int = 3600
|
||||
|
||||
@property
|
||||
def DATABASE_URL(self) -> str:
|
||||
"""构建数据库连接URL"""
|
||||
return (
|
||||
f"postgresql://{self.DB_USER}:{self.DB_PASSWORD}"
|
||||
f"@{self.DB_HOST}:{self.DB_PORT}/{self.DB_NAME}"
|
||||
)
|
||||
|
||||
@property
|
||||
def ASYNC_DATABASE_URL(self) -> str:
|
||||
"""构建异步数据库连接URL"""
|
||||
return (
|
||||
f"postgresql+asyncpg://{self.DB_USER}:{self.DB_PASSWORD}"
|
||||
f"@{self.DB_HOST}:{self.DB_PORT}/{self.DB_NAME}"
|
||||
)
|
||||
Reference in New Issue
Block a user