Forums

AttributeError: module 'sqlalchemy' has no attribute '__all__'

Hello. I am having this error setting up a database connection in flask_sqlalchemy. Please I need help with suggestions on how to fix it. Thanks in advance

Error running WSGI application
AttributeError: module 'sqlalchemy' has no attribute '__all__'
File "/var/www/uddes_pythonanywhere_com_wsgi.py", line 148, in <module>
from k_abby import app as application  # noqa

File "/home/uddes/k_abby/k_abby.py", line 18, in <module>
db = SQLAlchemy(app)

File "/usr/local/lib/python3.10/site-packages/flask_sqlalchemy/__init__.py", line 758, in __init__
_include_sqlalchemy(self, query_class)

File "/usr/local/lib/python3.10/site-packages/flask_sqlalchemy/__init__.py", line 112, in _include_sqlalchemy
for key in module.__all__:

It looks like there's a compatibility issue as all has been removed. Ensure that you are using Flask-SQLAlchemy 3.0.2 or later

Hello, I solved it by installing version 3.0.3 of Flask-SQLAlchemy, in the console: $pip install Flask-SQLAlchemy==3.0.3

I closed the console, run the app.py again and it worked.

I hope it works, regards.

Glad to hear that you made it work!