Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Load your database environment variables in the terminal session
# 1) Change the variables to your desired environment
# 2) Use the . ./ dev to run the script
# . dev ==> load dev environment variables
# . staging ==> load staging environment variables
# . production ==> load production environment variables
echo "Loading your database environment variables to your shell session..."
if [[ "${1}" == "dev" ]]; then
echo -e "Development Env"
DB_HOST_DEV="<Development database>"
export DB_PORT_DEV="<Development database port>"
export DB_USER_DEV="<Development database user>"
if [[ "${1}" == "staging" ]]; then
echo "Staging Env"
export DB_HOST_STAGING="<Staging database host>"
export DB_PORT_STAGING="<Staging database port>"
export DB_USER_STAGING="<Staging database user>"
if [[ "${1}" == "prod" ]]; then
echo -e "Production Env"
export DB_HOST_PROD="<Production database host>"
export DB_NAME_PROD="<Production database name>"
export DB_PORT_PROD="<Production database port>"
export DB_USER_PROD="<Production database user>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment