This is my first time working with SQL Alchemy, and I've got a model I'm trying to update here:
vpi = VendorPlatformIntegration.get_installed_integration_by_code(post_data["integration_code"], current_user.vendor)
if post_data["integration_code"] == "slack":
vpi.integration_config["shared_channel"] = post_data["channel_id"]
elif post_data["integration_code"] == "salesforce":
vpi.integration_config["sobject_to_integrate"] = post_data["sobject"]
commit_db(vpi)
It's getting the integration just fine, and when I add a print to print out the value of vpi.integration_config after I set the new dictionary value, it has the new dictionary value. But after it runs and I look at that row in the database, it hasn't been updated. The commit_db function looks like this:
def commit_db(obj):
try:
db.session.add(obj)
db.session.commit()
return True
except Exception as e:
print(e)
return False
The get_installed_integration_by_code function looks like this:
@staticmethod
def get_installed_integration_by_code(integration_code, vendor_id):
integrations = VendorPlatformIntegration.query.filter(VendorPlatformIntegration.vendor_id == vendor_id).all()
integration_to_return = None
for integration in integrations:
if integration.integration_rel.integration_code == integration_code:
integration_to_return = integration
break
return integration_to_return
Why are my changes to the model not being persisted in the database?