I want to store Rows values in a session variable. I realize I can't store
the Rows object directly, so I use rows.to_list(). The problem is that
where I used to be able to use attributes on the Rows object (e.g.,
rows[0].Meet.Name), now I would have to use string keys when I access the
list of dicts:
rows = db...select()
if rows[0].Meet.Name == ...
session.rowsList = rows.to_list()
...
rows = session.rowsList
if rows[0]['Meet']['Name'] == ...
Is there a simple way to convert the Rows object (or the result of the
to_list() call) to a Storage object? I can say:
rowStorage = Storage(rows.to_list())
but that only handles the "first-level" dicts. I would say:
rows[0].Meet['Name']
Realize that each Row (and each dict object in the to_list()) can have at
least ("at most," maybe) two levels of dicts. The select might have
selected from several tables. For example, a simplified result of a select
from two joined tables (Rows.to_list(), returning two rows):
[{'Person': {'City': 'Springs', 'First_name': 'Sue'},
'Meet': {'Start_datetime': datetime.datetime(2013, 1, 18, 18, 0)}},
{'Person': {'City': '...}}]
Yes, I can write the code; but does the code already exist...say
Rows.to_storage()?
Thanks.
--