PIbd-42_SSPR/settings.py
AnnZhimol 49e327005e Update Database:
+ch_experiment_data in click_house
+experiment_data and experiment_parameters in postgresql
+experiment_data has foreign_key from experiment_parameters
+new connections
+realize routes for ch_experiment_data
+new alg csv_to_db
+new methods in repos
+update dockerfile
+update readme "how to init db"
2024-10-25 01:02:31 +03:00

32 lines
1.0 KiB
Python

from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
DB_USER: str
DB_PASSWORD: str
DB_HOST: str
DB_PORT: int
DB_NAME: str
DATABASE: str
POSTGRES_USER: str
POSTGRES_PASSWORD: str
CLICKHOUSE_USER: str
CLICKHOUSE_PASSWORD: str
@property
def db_url_asyncpg(self):
# 'postgresql+asyncpg://username:password@localhost:5432/database_name'
return f'postgresql+asyncpg://{self.DB_USER}:{self.DB_PASSWORD}@{self.DB_HOST}:{self.DB_PORT}/{self.DB_NAME}'
@property
def db_url_asyncpg_docker(self):
# 'postgresql+asyncpg://username:password@localhost:5432/database_name'
return f'postgresql+asyncpg://{self.POSTGRES_USER}:{self.POSTGRES_PASSWORD}@db:{self.DB_PORT}/{self.DATABASE}'
@property
def clickhouse_url(self):
return f'clickhouse://{self.CLICKHOUSE_USER}:{self.CLICKHOUSE_PASSWORD}@clickhouse:8123/{self.DATABASE}'
model_config = SettingsConfigDict(env_file=".env")
settings = Settings()