Shell/Bash: install dotenv Example

By

Shell/Bash Example: This is the "install dotenv" Example. compiled from many sources on the internet by SimpleTutorials.org

dotenv python

# Install dotenv via:
pip3 install python-dotenv

# Load .env file using:
from dotenv import load_dotenv
load_dotenv()

# Use the variable with:
import os
os.getenv("ACCESS_KEY")

install dotenv

# For python users only
pip install python-dotenv

node dotenv

require('dotenv').config();

console.log(process.env.MY_ENV_VAR);

dotenv

$ npm install dotenv

//--------------------

on file .env 
//--------------------
DB_HOST=localhost
DB_USER=root
DB_PASS=s1mpl3
DB_NAME=banco_de_dados
DB_PORT=3306
//--------------------

import the config from .env file 
//--------------------

require('dotenv').config()
module.exports = {
    username:process.env.DB_USER,
    password:process.env.DB_PASS,
    database:process.env.DB_NAME,
    host:process.env.DB_HOST,
    dialect:"mysql"
}

python install dotenv

pip install python-dotenv

install dotenv

# with npm 
npm install dotenv
 
# or with Yarn 
yarn add dotenv


* Summary: This "install dotenv" Shell/Bash Example is compiled from the internet. If you have any questions, please leave a comment. Thank you!

Others