1# Install dotenv via:
2pip3 install python-dotenv
3
4# Load .env file using:
5from dotenv import load_dotenv
6load_dotenv()
7
8# Use the variable with:
9import os
10os.getenv("ACCESS_KEY")
11
1//first install this
2npm install dotenv
3
4//then add this on the top of the your code
5require("dotenv").config();
6
7//first create file with name of .env
8DB_HOST=localhost
9DB_USER=root
10DB_PASS=s1mpl3
11
12//then use it
13const db = require('db')
14db.connect({
15 host: process.env.DB_HOST,
16 username: process.env.DB_USER,
17 password: process.env.DB_PASS
18})
1
2$ npm install dotenv
3
4//--------------------
5
6on file .env
7//--------------------
8DB_HOST=localhost
9DB_USER=root
10DB_PASS=s1mpl3
11DB_NAME=banco_de_dados
12DB_PORT=3306
13//--------------------
14
15import the config from .env file
16//--------------------
17
18require('dotenv').config()
19module.exports = {
20 username:process.env.DB_USER,
21 password:process.env.DB_PASS,
22 database:process.env.DB_NAME,
23 host:process.env.DB_HOST,
24 dialect:"mysql"
25}
26
1const db = require('db')
2db.connect({
3 host: process.env.DB_HOST,
4 username: process.env.DB_USER,
5 password: process.env.DB_PASS
6})