22 lines
833 B
Python
22 lines
833 B
Python
from pydantic import Field, SecretStr
|
|
from pydantic_settings import BaseSettings
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
bot_token: SecretStr = Field('token', env="BOT_TOKEN")
|
|
debug: bool = Field(False, env="DEBUG")
|
|
postgres_user: str = Field('user', env="POSTGRES_USER")
|
|
postgres_password: SecretStr = Field('password', env="POSTGRES_PASSWORD")
|
|
postgres_db: str = Field('db', env="POSTGRES_DB")
|
|
postgres_host: str = Field('localhost', env="POSTGRES_HOST")
|
|
postgres_port: int = Field(15432, env="POSTGRES_PORT")
|
|
|
|
@property
|
|
def postgres_url(self) -> str:
|
|
return f"postgresql://{self.postgres_user}:{
|
|
self.postgres_password.get_secret_value()}@{self.postgres_host}:{self.postgres_port}/{self.postgres_db}"
|
|
|
|
class Config:
|
|
env_file = ".env"
|
|
env_file_encoding = "utf-8"
|