On Mon, 18 Sep 2006 20:09:48 +0200 Wolfgang Keller <[EMAIL PROTECTED]> wrote:
> Just because I don't want to have to take care of all this "transaction > management" myself, as this is complete rocket-science to me... I know not of ACID, but... rocket science this is not. trans = session.create_transaction() DoStuff(session) session.flush() # Oh noes we've written to the database! DoMoreStuff(session) if AllIsWell(): trans.commit() else: trans.rollback() If you've ever used save points in a video game, then you've used transaction management. It's like a little save point you can carry around, which disappears harmlessly when you restore your old save, or when you save your game. It's supported in the database across the phone line, so you don't have to have sqlalchemy keep all the pending stuff in memory, which is wasteful plus you can't query it. Instead you write everything to the database, and if something goes wrong you tell the database to rollback to the beginning of your transaction and it'll delete everything you've done since create_transaction(). There's two levels of safety: first sqlalchemy keeps the stuff in memory until you flush(), then the database keeps tabs on the stuff you write to it, until you commit(). Normally sqlalchemy does both levels with every flush(), but if you create a transaction now you have control of when the database rolls back or commits. ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users