On 2010-09-25 2:29 PM, Mark Erbaugh wrote:
If I retrieve data strictly for reporting or other read-only use,
e.g. the session will not be used to update data, should I expunge
the objects returned by the query from the session? If I just let
the session object go out of scope is that sufficient?
If you're not modifying the objects, then you don't have to do anything
at all. If you are modifying them, then as long as you don't call
commit() on the session, the changes will be discarded when the session
is deleted. (That's assuming you have autocommit==False).
(Also, I think go out of scope is ambiguous in Python, where what
really matters is whether there are other references to the session.
Only when the last reference is removed is the session garbage-collected
and the changes will discarded/rolled-back. Having a local variable
referencing the session go out of scope does nothing if there are
other non-local references to the same session. But you probably know
all that. :) )
--
Peter Hansen
--
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.