未设置DATABASE_URL(CS50) [英] DATABASE_URL is not set(CS50)

查看:51
本文介绍了未设置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"

这篇关于未设置DATABASE_URL(CS50)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆