Search code examples
pythonpostgresqlherokutweepyplotly-dash

Run two applications in Heroku and connect them using the PostgreSQL database


I am trying to build a full-stack web application using Python and Heroku.

There are two apps and they are connected using a common database (Heroku Postgres). The backend app streams live tweets from twitter and stores them in a database. In the frontend plotly-dash app, users can give an input query and the sentiments of the query are displayed in real-time. The app is perfectly running on my local server. But when I try to deploy it in Heroku, I am finding difficulty in deploying the two apps.

Am I supposed to deploy the apps separately using two applications? If so, how can I connect to the common database?


Solution

  • Am I supposed to deploy the apps separately using two applications?

    Yes.

    Heroku is designed to deploy one service at a time. One application per application.

    If so, how can I connect to the common database?

    Create one application with a Heroku Postgres addon, then add a second application to the existing database:

    heroku addons:attach <heroku-addon-name> -a <app-name>