Skip to content
Advertisement

Can’t access Postgres DB on Heroku app

I have a Python 2.7 / Flask app running on Heroku that scrapes data and I now want to store that information in a database.

I’ve tried to follow tutorials like this one and apply this to my case but I can’t get it to work. I have created & promoted my postgres database successfully on heroku.

I am fairly new to the Python project architecture and I suspect a simple problem in my setup.

Here is my project structure

JavaScript

Here is my init.py

JavaScript

Here is a portion of my views.py

JavaScript

Basically when I visit myapp/db I want to create one record with id, name and email (john, foo@bar.com).

Any thoughts?

Advertisement

Answer

It should be os.environ.get('DATABASE_URL')

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement