Alembic Properly config env.py file to use .env variables [duplicate]

I would suggest using dotenv (pip install python-dotenv) like so:

import os
from dotenv import load_dotenv

load_dotenv()

username = os.environ.get("USERNAME")
password = os.environ.get("PASSWORD")

(dotenv doesn't have any external library dependencies which is nice)