]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
example of using try-catch to do transaction commit/rollback was wrong in the docs
authorAnts Aasma <ants.aasma@gmail.com>
Sun, 20 Jan 2008 03:39:43 +0000 (03:39 +0000)
committerAnts Aasma <ants.aasma@gmail.com>
Sun, 20 Jan 2008 03:39:43 +0000 (03:39 +0000)
doc/build/content/session.txt

index e17987cf539b19b55c7d99ea5ac496523236d79f..d44bef50d95f9612a6c040aef6cf06bf1d488e78 100644 (file)
@@ -460,10 +460,10 @@ Alternatively, a transaction can be begun explicitly using `begin()`:
         item2 = sess.query(Item).get(2)
         item1.foo = 'bar'
         item2.bar = 'foo'
+        sess.commit()
     except:
         sess.rollback()
         raise
-    sess.commit()
 
 Session also supports Python 2.5's with statement so that the example above can be written as: