本文整理匯總了Python中azure.storage.TableService.query_tables方法的典型用法代碼示例。如果您正苦於以下問題:Python TableService.query_tables方法的具體用法?Python TableService.query_tables怎麽用?Python TableService.query_tables使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類azure.storage.TableService
的用法示例。
在下文中一共展示了TableService.query_tables方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from azure.storage import TableService [as 別名]
# 或者: from azure.storage.TableService import query_tables [as 別名]
class OrderTable:
def __init__(self):
self.table_service = TableService(account_name='portalvhdspbrd34f2fnbl',
account_key='y48JkXg+VcHQRCgsylJf4xV4Fd0AuJNkQKSwGhAR+BppHnFhkI+UHPOS/oYaTo0rqFCGQkEBW+thNFZNB9W8yg==')
def insert(self,ID,CustomerID,ProductID,Datetime,TotalPrice):
task = {'PartitionKey': 'Order',
'RowKey': ID,
'CustomerID' : CustomerID,
'ProductID' : ProductID,
'Datetime' : Datetime,
'TotalPrice' : TotalPrice}
try:
self.table_service.insert_entity('Order', task)
except:
print"azure.WindowsAzureConflictError: Order Conflict"
def listAll(self):
task1 = self.table_service.query_entities('Order', None, None, 1000)
task2 = self.table_service.query_entities('Order', None, None, 1000,
task1.x_ms_continuation['NextPartitionKey'],
task1.x_ms_continuation['NextRowKey'])
task3 = self.table_service.query_entities('Order', None, None, 1000,
task2.x_ms_continuation['NextPartitionKey'],
task2.x_ms_continuation['NextRowKey'])
task4 = self.table_service.query_entities('Order', None, None, 1000,
task3.x_ms_continuation['NextPartitionKey'],
task3.x_ms_continuation['NextRowKey'])
'''
task5 = self.table_service.query_entities('Order', None, None, 1000,
task4.x_ms_continuation['NextPartitionKey'],
task4.x_ms_continuation['NextRowKey'])
task6 = self.table_service.query_entities('Order', None, None, 1000,
task5.x_ms_continuation['NextPartitionKey'],
task5.x_ms_continuation['NextRowKey'])
task7 = self.table_service.query_entities('Order', None, None, 1000,
task6.x_ms_continuation['NextPartitionKey'],
task6.x_ms_continuation['NextRowKey'])
task8 = self.table_service.query_entities('Order', None, None, 1000,
task7.x_ms_continuation['NextPartitionKey'],
task7.x_ms_continuation['NextRowKey'])
task9 = self.table_service.query_entities('Order', None, None, 1000,
task8.x_ms_continuation['NextPartitionKey'],
task8.x_ms_continuation['NextRowKey'])
task10 = self.table_service.query_entities('Order', None, None, 1000,
task9.x_ms_continuation['NextPartitionKey'],
task9.x_ms_continuation['NextRowKey'])
'''
i=0
for task in task1:
i=i+1
'''
print("ID: %s, CustomerID: %s, ProductID: %s, Datetime: %s, TotalPrice: %s") %(task.RowKey,
task.CustomerID,task.ProductID,task.Datetime,task.TotalPrice)
'''
print(task.TotalPrice)
for task in task2:
i=i+1
print(task.TotalPrice)
print("Total Order: %s") %(i)
def TableInfo(self):
info=self.table_service.query_tables()
for i in info:
print(i.name)
示例2: TableServiceTest
# 需要導入模塊: from azure.storage import TableService [as 別名]
# 或者: from azure.storage.TableService import query_tables [as 別名]
#.........這裏部分代碼省略.........
self.assertTrue(created)
def test_create_table_fail_on_exist(self):
# Arrange
# Act
created = self.ts.create_table(self.table_name, True)
# Assert
self.assertTrue(created)
def test_create_table_with_already_existing_table(self):
# Arrange
# Act
created1 = self.ts.create_table(self.table_name)
created2 = self.ts.create_table(self.table_name)
# Assert
self.assertTrue(created1)
self.assertFalse(created2)
def test_create_table_with_already_existing_table_fail_on_exist(self):
# Arrange
# Act
created = self.ts.create_table(self.table_name)
with self.assertRaises(WindowsAzureError):
self.ts.create_table(self.table_name, True)
# Assert
self.assertTrue(created)
def test_query_tables(self):
# Arrange
self._create_table(self.table_name)
# Act
tables = self.ts.query_tables()
for table in tables:
pass
# Assert
tableNames = [x.name for x in tables]
self.assertGreaterEqual(len(tableNames), 1)
self.assertGreaterEqual(len(tables), 1)
self.assertIn(self.table_name, tableNames)
def test_query_tables_with_table_name(self):
# Arrange
self._create_table(self.table_name)
# Act
tables = self.ts.query_tables(self.table_name)
for table in tables:
pass
# Assert
self.assertEqual(len(tables), 1)
self.assertEqual(tables[0].name, self.table_name)
def test_query_tables_with_table_name_no_tables(self):
# Arrange
# Act
with self.assertRaises(WindowsAzureError):
示例3: TableServiceTest
# 需要導入模塊: from azure.storage import TableService [as 別名]
# 或者: from azure.storage.TableService import query_tables [as 別名]
#.........這裏部分代碼省略.........
self.assertTrue(created)
def test_create_table_fail_on_exist(self):
# Arrange
# Act
created = self.tc.create_table(self.table_name, True)
# Assert
self.assertTrue(created)
def test_create_table_with_already_existing_table(self):
# Arrange
# Act
created1 = self.tc.create_table(self.table_name)
created2 = self.tc.create_table(self.table_name)
# Assert
self.assertTrue(created1)
self.assertFalse(created2)
def test_create_table_with_already_existing_table_fail_on_exist(self):
# Arrange
# Act
created = self.tc.create_table(self.table_name)
with self.assertRaises(WindowsAzureError):
self.tc.create_table(self.table_name, True)
# Assert
self.assertTrue(created)
def test_query_tables(self):
# Arrange
self._create_table(self.table_name)
# Act
tables = self.tc.query_tables()
for table in tables:
pass
# Assert
tableNames = [x.name for x in tables]
self.assertGreaterEqual(len(tableNames), 1)
self.assertGreaterEqual(len(tables), 1)
self.assertIn(self.table_name, tableNames)
def test_query_tables_with_table_name(self):
# Arrange
self._create_table(self.table_name)
# Act
tables = self.tc.query_tables(self.table_name)
for table in tables:
pass
# Assert
self.assertEqual(len(tables), 1)
self.assertEqual(tables[0].name, self.table_name)
def test_query_tables_with_table_name_no_tables(self):
# Arrange
# Act
with self.assertRaises(WindowsAzureError):