示例#1
0
 def test_transaction(self):
     with Transaction.begin():
         john = User(name='jonh')
         steve = User(name='steve')
         Transaction.add(john)
         Transaction.add(steve)
     self.assertEqual(3, len(User.all()))
 def test_transaction(self):
     with Transaction.begin():
         john = User(name='jonh')
         steve = User(name='steve')
         Transaction.add(john)
         Transaction.add(steve)
     self.assertEqual(3, len(User.all()))
示例#3
0
 def trans():
     try:
         with Transaction.begin():
             john = User(id=999,name='jonh')
             steve = User(id=999,name='steve')
             Transaction.add(john)
             Transaction.add(steve)
     except SQLAlchemyError:
         Transaction.rollback()
         raise
 def trans():
     try:
         with Transaction.begin():
             john = User(id=999, name='jonh')
             steve = User(id=999, name='steve')
             Transaction.add(john)
             Transaction.add(steve)
     except SQLAlchemyError:
         Transaction.rollback()
         raise