sqlalchemy attribute is tuple after assignment


I’m using SQLAlchemy 1.0.12. When I have an instance of my model & assign a new value to an attribute, I get a tuple instead of the value.

<class 'tuple'>

This wreaks a bit of havoc when I try to use marshmallow-sqlalchemy 0.8.1 to do a dump:


The assigned basically doesn’t show up in the dumped data because it doesn’t know how to marshal a tuple. The only way to “flatten” the tuple/attributes is to do a session.commit() before doing a dump().

Is there a cleaner way? I have other instances to change/create before I want to do a session.commit().

Asked By: Foo L



It was a user error. I accidentally had a comma at the end of an assignment, and python created a tuple as the return value.

This returns an integer


This returns a tuple


Removing the comma in my return statement as suggested in the comments by Ilja worked

Answered By: Foo L
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.