You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
from pydantic_settings import BaseSettings
from typing import Optional
class Settings ( BaseSettings ) :
# 项目信息
PROJECT_NAME : str = " 期货统一数据平台 "
VERSION : str = " 0.1.0 "
API_PREFIX : str = " /api/v1 "
# 数据库配置
DB_HOST : str = " postgres "
DB_PORT : int = 5432
DB_NAME : str = " futures_data "
DB_USER : str = " futures "
DB_PASSWORD : str = " futures123 "
DATABASE_URL : str = " " # 直接指定完整 URL, 支持 sqlite:///
@property
def database_url ( self ) - > str :
if self . DATABASE_URL :
return self . DATABASE_URL
return f " postgresql:// { self . DB_USER } : { self . DB_PASSWORD } @ { self . DB_HOST } : { self . DB_PORT } / { self . DB_NAME } "
# Redis 配置
REDIS_HOST : str = " redis "
REDIS_PORT : int = 6379
REDIS_DB : int = 0
REDIS_PASSWORD : Optional [ str ] = None
@property
def REDIS_URL ( self ) - > str :
if self . REDIS_PASSWORD :
return f " redis://: { self . REDIS_PASSWORD } @ { self . REDIS_HOST } : { self . REDIS_PORT } / { self . REDIS_DB } "
return f " redis:// { self . REDIS_HOST } : { self . REDIS_PORT } / { self . REDIS_DB } "
# Tushare 配置
TUSHARE_TOKEN : str = " "
# 服务配置
HOST : str = " 0.0.0.0 "
PORT : int = 8000
DEBUG : bool = True
class Config :
env_file = " .env "
case_sensitive = True
settings = Settings ( )