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) … Read more

Flask-SQLAlchemy import/context issue

The flask_sqlalchemy module does not have to be initialized with the app right away – you can do this instead: # apps.members.models from flask_sqlalchemy import SQLAlchemy db = SQLAlchemy() class Member(db.Model): # fields here pass And then in your application setup you can call init_app: # apps.application.py from flask import Flask from apps.members.models import db … Read more

jsonify a SQLAlchemy result set in Flask [duplicate]

It seems that you actually haven’t executed your query. Try following: return jsonify(json_list = qryresult.all()) [Edit]: Problem with jsonify is, that usually the objects cannot be jsonified automatically. Even Python’s datetime fails 😉 What I have done in the past, is adding an extra property (like serialize) to classes that need to be serialized. def … Read more