import enum def row2dict(row): """ Generic function to convert a SQLAlchemy row to a dictionary. May not be the best practice implementing like this but works for the moment """ d = {} for column in row.__table__.columns: val = getattr(row, column.name) if isinstance(val, enum.Enum): val = val.value d[column.name] = val return d