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 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