On Jun 7, 2008, at 3:50 PM, Tomer wrote:
> > 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? when you use the DBAPI (which every SQLA driver does), anytime you get a hold of a connection, there is a transaction in progress. Depending on what database backend you're using, this might have different meaning; such as if you're using MySQL with ISAM tables, there isnt really much transactional. But generally, selecting from tables implies that those rows might be pulled into the transaction such that changes made external to the trans aren't visible (depending on isolation behavior). But this doesn't actually "write" anything to the database. Only INSERT/UPDATE/DELETE has that effect. When using the ORM, these operations are encapsulated entirely wihtin a flush(), so if your transaction does not flush(), then nothing is written. Doing a rollback() will ensure completely that nothing is written, even if flushes have taken place. With SQLA 0.4, rollback() has the caveat that the Session is not really usable after a rollback() until it is clear()'ed. With 0.5 this restriction is lifted. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---