Skip to content

Instantly share code, notes, and snippets.

@Itsindigo
Created June 2, 2024 02:33
Show Gist options
  • Save Itsindigo/d1cd54526738f258874a9fe01950fde5 to your computer and use it in GitHub Desktop.
Save Itsindigo/d1cd54526738f258874a9fe01950fde5 to your computer and use it in GitHub Desktop.
import os
from dotenv import load_dotenv
from pydantic_settings import BaseSettings
dotenv_path = f"{os.getcwd()}/.env"
load_dotenv(dotenv_path)
class AppConfig(BaseSettings):
"""
Uses pydantic_settings to load configuration from environment variables.
If env var is not found matching the attribute name, the default value is used.
"""
API_DB_NAME: str = "api_db" # Default values can be overridden by env vars
API_DB_USER: str = "immi"
API_DB_PASSWORD: str
API_DB_PORT: str = "5432"
ENABLE_DETAILED_SQL_LOGGING: bool = False
WEBHOOK_VERIFICATION_SECRET: str
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment