未设置DATABASE_URL(CS50)

未设置DATABASE_URL(CS50)

问题描述:

我正在处理cs50 project1(js和python),我下载了该项目,并在其中找到这一行:

I'm working on cs50 project1 (js & python), I download the project, and found this line in it:

engine = create_engine(os.getenv("DATABASE_URL"))

问题是如何设置DATABASE_URL?

the question is how to set up the DATABASE_URL?

在初始化您的应用后添加以下代码:

add this code after initialising your app:

app.config ['DATABASE_URL'] ="path_to_db"

或通过在命令行中运行来导出它:

Or export it by running in your command line:

export DATABASE_URL =" postgres://user:password @ server_ip:5432/table_name"