Thank you very much. Even though I suspected that issue to be related to that chapter, in 13 years I would not have come up with your solution.
You solved my problem, but I'm still curious about that <class 'sqlalchemy.util._collections.result'>, which does not really exist. I understand that it must be the new KeyedTuple implementation as it descends from tuple and has methods like keys(). But the exception message talks about a class that is clearly not there and can neither be imported nor used in isinstance(). On Sunday, July 19, 2015 at 9:58:42 PM UTC+2, Michael Bayer wrote: > > > > On 7/19/15 3:09 PM, Dirk Makowski wrote: > > Thanks for looking into it. Sorry about 7z, it's an archive. Please see > the revised attachment. > > > OK, that's some elaborate test script but ultimately this is your issue: > > if isinstance(inp, KeyedTuple): > return proc_keyed_tuple(inp) > > > should be: > > if isinstance(inp, tuple): > return proc_keyed_tuple(inp) > > see: > > > http://docs.sqlalchemy.org/en/latest/changelog/migration_10.html#new-keyedtuple-implementation-dramatically-faster > > > > > > In principle, I'm converting the result from a query into a list of > dicts. > > data = [] > rs = sess.query(...) > for r in rs: > data.append(dictate(r)) > > In function dictate() is the call to inspect(). Until SA 0.9.9 it worked > fine. With version 1.0.6 sometimes the call to inspect() fails with > honestly that error message. It depends on what was queried: > - a single ORM object: OK > - hand-made SQL (sa.text()): OK > - several joined ORM objects: FAIL > - mixture of ORM objects and columns: FAIL > > Attached script goes through these situations and shows exactly what > happens. > > > On Sunday, July 19, 2015 at 6:28:07 PM UTC+2, Michael Bayer wrote: >> >> >> >> On 7/19/15 11:58 AM, Dirk Makowski wrote: >> >> Hello all, >> >> some time ago I wrote a function to mogrify SA query results into a >> list of dicts. It uses the inspector to determine columns etc. Up until SA >> 0.9.9 it worked well. However, after an upgrade of SA to 1.0.6 in some >> circumstances I get this error: >> >> No inspection system is available for object of type <class >> 'sqlalchemy.util._collections.result'> >> >> What previously had been a Python type or ORM type now is an ominous >> 'result'. >> >> Hopefully you can give some pointers about what it is and how I could >> fix my function. A test case with more info in the sources is attached. >> Apart from SA it does have no external dependencies. >> >> >> The error is that you are calling inspect() on something that does not >> support inspection. There's no object in util._collections called "result" >> so I don't know what that is. >> >> > >> Also I don't know what a "7z" file is. Can you please send a single, >> very succinct .py file with a simple illustration of your error? Thanks. >> >> >> >> Thank you, >> >> Dirk >> >> -- >> You received this message because you are subscribed to the Google Groups >> "sqlalchemy" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To post to this group, send email to [email protected]. >> Visit this group at http://groups.google.com/group/sqlalchemy. >> For more options, visit https://groups.google.com/d/optout. >> >> >> -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] <javascript:>. > To post to this group, send email to [email protected] > <javascript:>. > Visit this group at http://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/d/optout. > > > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
