本文整理汇总了Python中platemap.lib.sql_connection.TRN.execute_fetchflatten方法的典型用法代码示例。如果您正苦于以下问题:Python TRN.execute_fetchflatten方法的具体用法?Python TRN.execute_fetchflatten怎么用?Python TRN.execute_fetchflatten使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类platemap.lib.sql_connection.TRN
的用法示例。
在下文中一共展示了TRN.execute_fetchflatten方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_execute_fetchflatten
# 需要导入模块: from platemap.lib.sql_connection import TRN [as 别名]
# 或者: from platemap.lib.sql_connection.TRN import execute_fetchflatten [as 别名]
def test_execute_fetchflatten(self):
with TRN:
sql = """INSERT INTO barcodes.test_table (str_column, int_column)
VALUES (%s, %s)"""
args = [['insert1', 1], ['insert2', 2], ['insert3', 3]]
TRN.add(sql, args, many=True)
sql = "SELECT str_column, int_column FROM barcodes.test_table"
TRN.add(sql)
sql = "SELECT int_column FROM barcodes.test_table"
TRN.add(sql)
obs = TRN.execute_fetchflatten()
self.assertEqual(obs, [1, 2, 3])
sql = "SELECT 42"
TRN.add(sql)
obs = TRN.execute_fetchflatten(idx=3)
self.assertEqual(obs, ['insert1', 1, 'insert2', 2, 'insert3', 3])
示例2: test_rollback_transaction
# 需要导入模块: from platemap.lib.sql_connection import TRN [as 别名]
# 或者: from platemap.lib.sql_connection.TRN import execute_fetchflatten [as 别名]
def test_rollback_transaction(self):
# Create decorated test function that adds a table
@rollback_transaction
def testfunc():
with TRN:
sql = 'CREATE TABLE barcodes.rollback(test varchar NOT NULL)'
TRN.add(sql)
TRN.execute()
# Make sure that table does not exist once function completes
testfunc()
with TRN:
sql = """SELECT *
FROM information_schema.tables
WHERE table_schema = 'barcodes'"""
TRN.add(sql)
obs = TRN.execute_fetchflatten()
self.assertNotIn('rollback', obs)