Discussion:
AttributeError: ResultProxy instance has no attribute '__len__'
George Sakkis
2006-10-20 01:53:55 UTC
Permalink
I tried to get the length of a result set and I ran into the this
error. While I understand that ResultProxy is modeled more like an
iterator than a sequence, I introspected the proxy object and it turns
out it has a 'rowcount' attribute which stores the expected length. Is
there a reason why there's not a __len__ that returnes this rowcount ?

Thanks,
George


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To post to this group, send email to ***@googlegroups.com
To unsubscribe from this group, send email to sqlalchemy-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sqlalchemy
-~----------~----~----~----~------~----~------~--~---
Michael Bayer
2006-10-20 02:31:54 UTC
Permalink
rowcount stores the number of rows that were located during an INSERT,
UPDATE, or DELETE statement, and is undefined during SELECT. the
"length" of a result set is generally not known until it is completely
fetched, as the database typcially starts returning rows over the wire
before it has even finished locating all rows (unless the results were
ordered or otherwise grouped in some way).

to get the length of a particular result usually entails either fully
fetching the result, or calling a separate select of "count()" with the
same criterion.
Post by George Sakkis
I tried to get the length of a result set and I ran into the this
error. While I understand that ResultProxy is modeled more like an
iterator than a sequence, I introspected the proxy object and it turns
out it has a 'rowcount' attribute which stores the expected length. Is
there a reason why there's not a __len__ that returnes this rowcount ?
Thanks,
George
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To post to this group, send email to ***@googlegroups.com
To unsubscribe from this group, send email to sqlalchemy-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sqlalchemy
-~----------~----~----~----~------~----~------~--~---

Loading...