cs50/python-cs50

Heroku docs: Postgres URI won't work if not changed to postgresql://

alfredoguillem opened this issue · 2 comments

And can't edit the URI on Heroku.

In the docs, step 16 is now:

In CS50 IDE, open application.py in finance/ and replace

db = SQL("sqlite:///finance.db")

with

db = SQL(os.getenv("DATABASE_URL"))

Instead, it could be something like:

In CS50 IDE, open application.py in finance/ and replace

db = SQL("sqlite:///finance.db")

with

uri = os.getenv("DATABASE_URL") 
if uri.startswith("postgres://"):
    uri = uri.replace("postgres://", "postgresql://", 1)
db = SQL(uri)

This fixes the issue.

What symptom (or error message specifically) were you seeing when the URI started with postgres://?

postgres:// should be supported in v7.0.1 but deprecated. Will not be supported in the next major release. You should use postgresql:// instead.