This problem seems very simple, but I'm having trouble finding an already existing solution on StackOverflow.
When I run a sqlalchemy command like the following
valid_columns = db.session.query(CrmLabels).filter_by(user_id=client_id).first()
I get back a CrmLabels object that is not iterable. If I print this object, I get a list
[Convert Source, Convert Medium, Landing Page]
But this is not iterable. I would like to get exactly what I've shown above, except as a list of strings
['Convert Source', 'Convert Medium', 'Landing Page']
How can I run a query that will return this result?
evalbut it should be avoided. Other than that I can not think of any other way.CrmLabelsclass.session.query(CrmLabels.name)eval. If you want to query the whole table, but as result tuples instead of mapped objects, usequery(CrmLabels.__table__). But I think this seems a bit like an XY problem.