Skip to content

Instantly share code, notes, and snippets.

@morkesiden
Forked from dineshkumarkb/pydantic_config.py
Created September 23, 2022 17:59
Show Gist options
  • Select an option

  • Save morkesiden/910b8ae841c7c6e8d97858d5f0ae15fd to your computer and use it in GitHub Desktop.

Select an option

Save morkesiden/910b8ae841c7c6e8d97858d5f0ae15fd to your computer and use it in GitHub Desktop.
from pydantic import BaseSettings
class Settings(BaseSettings):
DB_NAME: str = 'local'
DB_USER: str = 'localuser'
DB_HOST: str = "mysql.localhost.com"
DB_PASSWORD: str
API_ENDPOINT: str
class Config:
env_file = ".env"
settings = Settings()
print(settings.API_ENDPOINT)
print(settings.DB_HOST)
print(settings.DB_NAME)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment