當前位置: 首頁>>代碼示例>>Python>>正文


Python TableService.query_tables方法代碼示例

本文整理匯總了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)
開發者ID:freshmenyuan,項目名稱:PointOfSale,代碼行數:69,代碼來源:OrderTable.py

示例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):
開發者ID:algaruda,項目名稱:azure-sdk-for-python,代碼行數:70,代碼來源:test_tableservice.py

示例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):
開發者ID:Bunkerbewohner,項目名稱:azure-sdk-for-python,代碼行數:70,代碼來源:test_tableservice.py


注:本文中的azure.storage.TableService.query_tables方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。