问题
I am using postgres on Mac. I have a database up and running. I want to use it with Flask (SQL Alchemy) but the DATABASE_URL
environment variable didn't create itself (I think it's supposed to do that). Here is the code I tried running:
import os
print(os.getenv("DATABASE_URL"))
And there's no output. How can I set the variable (if I need to set it up manually).
回答1:
Yes, you have to do that manually. So, within your terminal do this:
% cd
% nano .bash_profile
It will open a file 'bash_profile' in editor in your terminal. And in there you can set environmental variables like:
export DATABASE_URL="YOUR DATABASE URL"
Check this video out for more info: https://youtu.be/5iWhQWVXosU
来源:https://stackoverflow.com/questions/61901732/how-to-set-database-url-environment-variable-for-postgres-mac-terminal