When I was using session.query, I was able to convert the result to a list of dicts :
my_query = session.query(table1,table2).filter(all_filters)
result_dict = [u.__dict__ for u in my_query.all()]
But now that I have to work with the SELECT()
operation, how can I convert the results to a dict that looks like, for every row result :
[{'Row1column1Name' : 'Row1olumn1Value', 'Row1column2Name' :'Row1Column2Value'},{'Row2column1Name' : 'Row2olumn1Value', 'Row2column2Name' : 'Row2Column2Value'},etc....]
.
This is my SELECT() code :
select = select([table1,table2]).where(all_filters)
res = conn.execute(select)
row = res.fetchone() #I have to use fetchone() because the query returns lots of rows
resultset=[]
while row is not None:
row = res.fetchone()
resultset.append(row)
print resultset
The result is :
[('value1', 'value2', 'value3', 'value4'),(.....),etc for each row]
I'm new to Python, any help would be appreciated.