q.all()._asdict()
It does not work. It is a kind of a mental shortcut (sorry for that!). It
is only possible in (like you said):
for r in q.all():
r._as_dict()
Thank you for your reply! I had hope that I don't have to do any casting or
explicity query enumerate.
W dniu czwartek, 20
I'm sorry, I totally misunderstood your question. I thought you were trying
to get all rows as a unified dict. Your result clarified things.
It looks like you're using the ORM (and not core), right?
I don't think it is entirely possible to do what you want. Several people
have asked similar
q.all() returns me a result in format:
[('one', {'t2c2': 'qwe',
't2c1': '11',
't2c3': '1'}),
('two', {'t2c2': 'rty',
't2c1': '22',
't2c3': '2'}),
..]
The result of
q.all()._asdict()
is
[{
't1c2': 'one',
'table2': {
't2c2': 'qwe',
't2c1': '11',
't2c3': '1'
}
},
{
Your query's underlying sql returns multiple rows. You can cast those
results into a dict in Python.
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable
Example. See