本文整理匯總了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)