read-dotenv-files

This repository contains small scripts as well as instructions to read .env files in several languages.

View the Project on GitHub Baelfire18/read-dotenv-files

Python Dotenv

For using it in python first you have to have:

  1. A Python version installed.

  2. Optionally having a python virtual enviroment.

  3. Installed the python-dotenv package. You can do it just by running pip install python-dotenv.

For a .env file like this:

from os import environ
from dotenv import load_dotenv

load_dotenv(".env")

DB_NAME = environ["DB_NAME"]
print(DB_NAME)