My commit does not save any changes to the database:
# project/models.py
from project import db
from sqlalchemy.dialects.postgresql import JSON
class Customer(db.Model):
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
clientid = db.Column(db.String(64))
...
contextjason = db.Column(JSON)
# project/__init__.py
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
db = SQLAlchemy(app)
from project.models import Customer
custObj = Customer.query.filter(Customer.custid == custid).first()
print(custObj.contextjason) # works fine
custObj.contextjason = { 'foo':'bar', 'so':'be it'}
db.session.commit()
The commit does not commit any changes to the DB. Actually, I don't know what it does in the background.
Can anybody tell me why I have no DB update?
Can I tell the commit somehow to log what it is doing (maybe SQL wise)?
Edit:
with SQLALCHEMY_ECHO=True
I get this for the commit:
2018-05-23 16:42:17,102 INFO sqlalchemy.engine.base.Engine COMMIT