25 lines
829 B
Python
25 lines
829 B
Python
# app/config.py
|
|
import os
|
|
from pydantic_settings import BaseSettings
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv()
|
|
|
|
class Settings(BaseSettings):
|
|
DATABASE_URL: str | None = None
|
|
|
|
class Config:
|
|
env_file = ".env"
|
|
env_file_encoding = 'utf-8'
|
|
extra = "ignore"
|
|
|
|
settings = Settings()
|
|
|
|
# Basic validation to ensure DATABASE_URL is set
|
|
if settings.DATABASE_URL is None:
|
|
print("Error: DATABASE_URL environment variable not set.")
|
|
# Consider raising an exception for clearer failure
|
|
# raise ValueError("DATABASE_URL environment variable not set.")
|
|
# else: # Optional: Log the URL being used (without credentials ideally) for debugging
|
|
# print(f"DATABASE_URL loaded: {settings.DATABASE_URL[:settings.DATABASE_URL.find('@')] if '@' in settings.DATABASE_URL else 'URL structure unexpected'}")
|