Thanks. What would happen if I didn't do anything (I've seen lots of examples online that will just issue a query like Session.query(User).all() and that's all). Will that query start a transaction if it's a transactional session?
On Jun 7, 11:58 am, [EMAIL PROTECTED] wrote: > On Saturday 07 June 2008 21:35:35 Tomer wrote: > > > If I am just issuing a read-only query, and I want to make sure > > that nothing will change in the middle, do I need a transaction? If > > so, what do I do with it when I'm done - commit or rollback? > > > For example, I want to do this: > > > for user in Session.query(User): > > print user.name > > > Should I use a transaction like this: > > > Session.begin() > > for user in Session.query(User): > > print user.name > > Session.commit() > > If not, how would I deal with this if my session (created with > > scoped_session) is transactional? > > if the __str__ happens to self-change (well, shit happens), then u > should not do commit nrt flush. the safest is to rollback - > regardless what u do. or maybe close() or clear()? > i think there was some way to make the session readonly alltogether -- > but i'm not sure. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---
