Home > other >  How to know if SQLAlchemy database migrations were done correctly on heroku?
How to know if SQLAlchemy database migrations were done correctly on heroku?

Time:09-17

I am developing an application with python, flask and using SQLAlchemy as the database.

On my local machine the code is working perfectly, when I deployed it to heroku I got the error The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

Then I noticed that I hadn't done the database migrations, so I searched the internet and found this material: Setting up flask app in heroku with a database. I followed it step by step, but I still had the same initial problem.

To find out in more detail what the error was I tried to implement a log file, but it didn't work.

from logging import FileHandler,WARNING

file_handler = FileHandler('errorlog.txt')
file_handler.setLevel(WARNING)

How can I get more information about this error that came up or to know if the SQLAlchemy database is working properly?

CodePudding user response:

Log to stdout or stderr, e.g.

from logging import StreamHandler, WARNING

stream_handler = StreamHandler()  # Defaults to sys.stderr
stream_handler.setLevel(WARNING)

The output will be included in the Heroku's standard log stream, which you can view by running heroku logs or the dashboard.

  • Related