AttributeError: can’t set attribute when connecting to sqlite database with flask-sqlalchemy

Edit

If you’re experiencing this, upgrading Flask-SQLAlchemy to >= 2.5 should resolve the issue per https://github.com/pallets/flask-sqlalchemy/issues/910#issuecomment-802098285.

Pinning SQLAlchemy to ~1.3 should no longer be necessary.


I ran into this issue a little earlier, but think I’ve figured out what’s going on.

SQLAlchemy is automatically installed as a dependency for Flask-SQLAlchemy and its latest release (1.4.0) introduces the following breaking change:

The URL object is now an immutable named tuple. To modify a URL object, use the URL.set() method to produce a new URL object.

I was able to fix this issue by simply installing the previous version of SQL Alchemy (1.3.23).

Leave a Comment