本文整理匯總了Python中platemap.lib.sql_connection.TRN.commit方法的典型用法代碼示例。如果您正苦於以下問題:Python TRN.commit方法的具體用法?Python TRN.commit怎麽用?Python TRN.commit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類platemap.lib.sql_connection.TRN
的用法示例。
在下文中一共展示了TRN.commit方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_execute_commit_false
# 需要導入模塊: from platemap.lib.sql_connection import TRN [as 別名]
# 或者: from platemap.lib.sql_connection.TRN import commit [as 別名]
def test_execute_commit_false(self):
with TRN:
sql = """INSERT INTO barcodes.test_table (str_column, int_column)
VALUES (%s, %s) RETURNING str_column, int_column"""
args = [['insert1', 1], ['insert2', 2], ['insert3', 3]]
TRN.add(sql, args, many=True)
obs = TRN.execute()
exp = [[['insert1', 1]], [['insert2', 2]], [['insert3', 3]]]
self.assertEqual(obs, exp)
self._assert_sql_equal([])
TRN.commit()
self._assert_sql_equal([('insert1', True, 1), ('insert2', True, 2),
('insert3', True, 3)])
示例2: test_context_manager_checker
# 需要導入模塊: from platemap.lib.sql_connection import TRN [as 別名]
# 或者: from platemap.lib.sql_connection.TRN import commit [as 別名]
def test_context_manager_checker(self):
with self.assertRaises(RuntimeError):
TRN.add("SELECT 42")
with self.assertRaises(RuntimeError):
TRN.execute()
with self.assertRaises(RuntimeError):
TRN.commit()
with self.assertRaises(RuntimeError):
TRN.rollback()
with TRN:
TRN.add("SELECT 42")
with self.assertRaises(RuntimeError):
TRN.execute()