Load .env file automatically on startup (#104)
Add automatic .env file loading using python-dotenv. This searches the current working directory and parent directories for a .env file and loads environment variables from it. Uses override=True so .env file values take precedence over existing shell environment variables, which is the expected behavior when running from a project directory.
This commit is contained in:
parent
39e3f7c528
commit
c06d9b4e4f
1 changed files with 5 additions and 0 deletions
|
|
@ -8,6 +8,11 @@ import logging
|
|||
import os
|
||||
from dataclasses import dataclass
|
||||
|
||||
from dotenv import find_dotenv, load_dotenv
|
||||
|
||||
# Load .env file, searching current and parent directories (overrides existing env vars)
|
||||
load_dotenv(find_dotenv(usecwd=True), override=True)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Environment variable names
|
||||
|
|
|
|||
Loading…
Reference in a new issue