Can I deploy an API in Heroku with an existing connection with pymysql? "Can't connect to MySQL server on 'localhost' [Errno 111] Connection refused

Viewed 64

The global idea is to extract some information from a Database (Locally hosted by MySQL) then filter the information using SQLAlchemy to finally create the get statements in the FastAPI app. This works wonderful locally, however when I try to deploy the app in Heroku I get the following error:

sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)")

Now I'm wondering if I can create the connection to local hosted database and Heroku, if so, how?

Any help would be so appreciated!

0 Answers
Related