On Dec 14, 2008, at 12:40 PM, J Stam wrote:
> > Within a contextual session, multiple queries all seem to return the > same data even though with SQL logging I can see the data has been > changed by another thread and a SELECT has been issued by the query. Changes from other transactions will not be visible until SQL is re- issued in a transaction that's begun after those transactions have been completed (assuming you're using a system that features transaction isolation, which is most). To satisfy the transactional requirement, the session's transaction needs to be ended either via rollback or commit (or close(), which is essentially a rollback). This also happens implicitly after each operation if autocommit=True. To satisfy the re-issuing of SQL requirement, the contents of the session need to be expired (which is automatic after an explicit rollback() or commit(), or occurs via expire_all()), or removed entirely (which is a clear() or close(), or a remove() when using a contextual session). The session is designed to perform these tasks most closely corresponding to the actual database transaction when you use autocommit=False,autoflush=True,expire_on_commit=True, which also produces the maximum back-and-forth SQL traffic. Adjusting these elements will change the steps required to achieve this result, but the essential facts that SQL needs to be re-issued in a fresh transaction are universal to all scenarios. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
