I recently (today) ran into an issue that has me perplexed as to how to resolve it, so I'm asking here to see if anyone can shed some insight. Hopefully I can ex- plain it clearly enough to make me not sound completely incompetent...
I currently have an application that during it's run starts a session via SQLAlchemy to one of our databases and keeps it available until the program exits. During this time it does multiple changes (primarily inserts and updates) to the database, but of course nothing is actually written to the database until a commit() is done. The problem is that there are times when I have a single change that must be available in the database immediately due to external resources needing to access to that updated/new information. Initially I thought that using 'begin_nested()' .. 'commit()' would accomplish this (possibly naively), but found out today in a very bad way that it did not; after re- reading the documentation this became abundantly clear. Further analysis of my current code revealed that I actually do not need to have 'isolated' commits from within a transaction, but I have this feeling as I expand my usage of the library I've created to deal with the database access I may find a need for this; the only other option is to keep track of every single change in any application that re- quires this and create a 'reverse' set of changes if I need to rollback. So this leads to the question: is there any way to do an 'isolated' commit from within a session and if so, how is it done? As an alternative, is there a way to use temporary new sessions to accomplish the same thing? My current use in my application is I have a 'Session = scoped_session(sessionmaker())' line in a module which I import wherever I need it (essentially as a singleton) to be able to access the same session throughout the code. This would of course need to change, at least with an application requiring such 'sub commits'. If any further clarification is needed on the above, please don't hesitate to ask, and I thank folks in advance for any assistance they can give. -- - Ken Lareau -- 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 sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.