pythonflaskherokuflask-sqlalchemydyno

How to stop heroku dyno restart from reseting my database


I have a flask app on heroku. Originally I had a free Dyno from heroku. When my website was inactive for 30 mins it would sleep, consequently reseting my database.

I then upgraded to a Hobby Dyno. This solved the issue of the dyno sleeping. Although it still has a daily restart causing my database to reset. Is there a way to stop this from happening?


Solution

  • Assuming you start the application with python main.py, then your main file should be referenced as __main__ according to Python import rules. So in your blueprint, when you import the socketio object you should do it like this:

    from __main__ import socketio