当前位置: 首页>>代码示例>>Python>>正文


Python connect.rollback方法代码示例

本文整理汇总了Python中DBUtils.SteadyDB.connect.rollback方法的典型用法代码示例。如果您正苦于以下问题:Python connect.rollback方法的具体用法?Python connect.rollback怎么用?Python connect.rollback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBUtils.SteadyDB.connect的用法示例。


在下文中一共展示了connect.rollback方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test04_Connection

# 需要导入模块: from DBUtils.SteadyDB import connect [as 别名]
# 或者: from DBUtils.SteadyDB.connect import rollback [as 别名]

#.........这里部分代码省略.........
     self.assert_(hasattr(db._con, 'database'))
     self.assertEqual(db._con.database, 'SteadyDBTestDB')
     self.assert_(hasattr(db._con, 'user'))
     self.assertEqual(db._con.user, 'SteadyDBTestUser')
     self.assert_(hasattr(db, 'cursor'))
     self.assert_(hasattr(db, 'close'))
     self.assertEqual(db._con.open_cursors, 0)
     for i in range(3):
         cursor = db.cursor()
         self.assertEqual(db._con.open_cursors, 1)
         cursor.close()
         self.assertEqual(db._con.open_cursors, 0)
     cursor = []
     for i in range(3):
         cursor.append(db.cursor())
         self.assertEqual(db._con.open_cursors, i + 1)
     del cursor
     self.assertEqual(db._con.open_cursors, 0)
     cursor = db.cursor()
     self.assert_(hasattr(cursor, 'execute'))
     self.assert_(hasattr(cursor, 'fetchone'))
     self.assert_(hasattr(cursor, 'callproc'))
     self.assert_(hasattr(cursor, 'close'))
     self.assert_(hasattr(cursor, 'valid'))
     self.assert_(cursor.valid)
     self.assertEqual(db._con.open_cursors, 1)
     for i in range(3):
         self.assertEqual(db._usage, i)
         self.assertEqual(db._con.num_uses, i)
         self.assertEqual(db._con.num_queries, i)
         cursor.execute('select test%d' % i)
         self.assertEqual(cursor.fetchone(), 'test%d' % i)
     self.assert_(cursor.valid)
     self.assertEqual(db._con.open_cursors, 1)
     for i in range(4):
         cursor.callproc('test')
     cursor.close()
     self.assert_(not cursor.valid)
     self.assertEqual(db._con.open_cursors, 0)
     self.assertEqual(db._usage, 7)
     self.assertEqual(db._con.num_uses, 7)
     self.assertEqual(db._con.num_queries, 3)
     cursor.close()
     cursor.execute('select test8')
     self.assert_(cursor.valid)
     self.assertEqual(db._con.open_cursors, 1)
     self.assertEqual(cursor.fetchone(), 'test8')
     self.assertEqual(db._usage, 8)
     self.assertEqual(db._con.num_uses, 8)
     self.assertEqual(db._con.num_queries, 4)
     self.assert_(db._con.valid)
     db.close()
     self.assert_(not db._con.valid)
     self.assertEqual(db._con.open_cursors, 0)
     self.assertEqual(db._usage, 8)
     self.assertEqual(db._con.num_uses, 0)
     self.assertEqual(db._con.num_queries, 0)
     self.assertRaises(InternalError, db._con.close)
     db.close()
     self.assertRaises(InternalError, db._con.cursor)
     cursor = db.cursor()
     self.assert_(db._con.valid)
     cursor.execute('select test11')
     self.assertEqual(cursor.fetchone(), 'test11')
     cursor.execute('select test12')
     self.assertEqual(cursor.fetchone(), 'test12')
     cursor.callproc('test')
     self.assertEqual(db._usage, 3)
     self.assertEqual(db._con.num_uses, 3)
     self.assertEqual(db._con.num_queries, 2)
     cursor2 = db.cursor()
     self.assertEqual(db._con.open_cursors, 2)
     cursor2.execute('select test13')
     self.assertEqual(cursor2.fetchone(), 'test13')
     self.assertEqual(db._con.num_queries, 3)
     db.close()
     self.assertEqual(db._con.open_cursors, 0)
     self.assertEqual(db._con.num_queries, 0)
     cursor = db.cursor()
     self.assert_(cursor.valid)
     cursor.callproc('test')
     cursor._cursor.valid = False
     self.assert_(not cursor.valid)
     self.assertRaises(InternalError, cursor._cursor.callproc, 'test')
     cursor.callproc('test')
     self.assert_(cursor.valid)
     cursor._cursor.callproc('test')
     self.assertEqual(db._usage, 2)
     self.assertEqual(db._con.num_uses, 3)
     db._con.valid = cursor._cursor.valid = False
     cursor.callproc('test')
     self.assert_(cursor.valid)
     self.assertEqual(db._usage, 1)
     self.assertEqual(db._con.num_uses, 1)
     cursor.execute('set doit')
     db.commit()
     cursor.execute('set dont')
     db.rollback()
     self.assertEqual(db._con.session,
         ['doit', 'commit', 'dont', 'rollback'])
开发者ID:SongJLG,项目名称:johan-doc,代码行数:104,代码来源:TestSteadyDB.py


注:本文中的DBUtils.SteadyDB.connect.rollback方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。