I am trying to deploy Python code and connect to my database following this tutorial to get the database URL. In my Procfile
I have:
web: DATABASE_URL=$(heroku config:get DATABASE_URL -a tmaminapi) python final.py
After deploying I see this in my logs:
2020-12-25T09:02:11.462258+00:00 heroku[web.1]: Starting process with command `DATABASE_URL=$(heroku config:get DATABASE_URL -a tmaminapi) python final.py`
2020-12-25T09:02:14.000000+00:00 app[api]: Build succeeded
2020-12-25T09:02:14.800250+00:00 app[web.1]: bash: heroku: command not found
That means I can't get the DATABASE_URL
environment variable as I expected. Why can't Heroku can't find the heroku
command-line tool in their own application?
Your Procfile
should just contain
web: python final.py
Heroku config vars are available in the environment by default, so there is no need to set them yourself in your Procfile
.
In general, there should never be a need to use the heroku
CLI from your dynos and therefore it isn't installed there. The documentation you referenced is specifically for accessing Heroku Postgres databases from outside of Heroku.