Hi, I’m looking for some guidance / resources on how to properly link a fly.io DB with my Flask python app - on local it’s working due to local mysql database - but it does not work properly when deployed as-is to fly (even though no errors) - I suspect due to lack of DB.
Would appreciate some tips, don’t see anything easily referencable on google or search here
Thx!
I’ve been able to run the app on local, using the fly.io postrgres database by proxying to localhost. So I assume that my app is working correctly (at local).
So it works fine when using this link on local:
SQLALCHEMY_DATABASE_URI = ‘postgresql://user:pwd@localhost:5432’
However, when I change it back to the original
SQLALCHEMY_DATABASE_URI = ‘postgresql://user:pwd@ht-new-db.internal:5432’
and deploy, the app does not work.
Not sure if that is app-db problem, or is it a problem with building the various requirement libraries I want to have. E.g. psycopg2 library is often problematic to build.
Would using docker help here somehow? Can someone suggest a solution?
This is the source of your current error. Are you sure you don’t have an attempted MySQL connection somewhere in your setup? Perhaps in apps/__init__.py? It looks like SQLAlchemy is trying to use it somewhere (Maybe try searching your repo. Are you using migrations? Were you using MySQL previously?
The brute-force solution is simply to add the most recent version of mysqlclient to your requirements, just to see whether you get further in the deploy process, but you really shouldn’t need it.
Somehow I resolved that, apparently this error happens when the link to the db is incorrect. I was placing my link in debug mode and the fly.io deploy was using prod variables, which had the db link missing.