Hello.
I have a hard time to understand the following comment for Query.yield_per():
Yield only ``count`` rows at a time.
WARNING: use this method with caution; if the same instance is present
in more than one batch of rows, end-user changes to attributes will be
overwritten.
In particular, it's usually impossible to use this setting with
eagerly loaded collections (i.e. any lazy='joined' or 'subquery')
since those collections will be cleared for a new load when
encountered in a subsequent result batch. In the case of 'subquery'
loading, the full result for all rows is fetched which generally
defeats the purpose of :meth:`~sqlalchemy.orm.query.Query.yield_per`.
Also note that many DBAPIs do not "stream" results, pre-buffering
all rows before making them available, including mysql-python and
psycopg2. :meth:`~sqlalchemy.orm.query.Query.yield_per` will also
set the ``stream_results`` execution
option to ``True``, which currently is only understood by psycopg2
and causes server side cursors to be used.
Suppose I have a code like this:
q = session.query(cls).filter(...)
q = q.options(
joinedload(cls.foo),
subqueryload(cls.bars),
)
for each in q.yield_per(50):
# access each.foo or each.bars
Does it work? Is so, why? If not, why?
I am using PostgreSQL 9.1 with psycopg2.
Thank you in advance,
Ladislav Lenart
--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.