from azure.data.tables import TableEntity task = TableEntity() task.PartitionKey = 'myPartition' task.RowKey = '1' task.description = 'My task' task.priority = 300 print(task.PartitionKey) # Output: 'myPartition'
from azure.data.tables import TableClient from azure.core.exceptions import ResourceNotFoundError table_name = "myTableName" connection_string = "DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=mykey;EndpointSuffix=core.windows.net" table_client = TableClient.from_connection_string(connection_string, table_name) try: task = table_client.get_entity(partition_key='myPartition', row_key='1') print(task.description) # Output: 'My task' except ResourceNotFoundError: print('Entity not found')
from azure.data.tables import TableClient from azure.data.tables import UpdateMode table_name = "myTableName" connection_string = "DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=mykey;EndpointSuffix=core.windows.net" table_client = TableClient.from_connection_string(connection_string, table_name) task = table_client.get_entity(partition_key='myPartition', row_key='1') task.priority = 500 table_client.update_entity(mode=UpdateMode.REPLACE, entity=task) updated_task = table_client.get_entity(partition_key='myPartition', row_key='1') print(updated_task.priority) # Output: 500Overall, 'TableEntity' is a key class for working with Azure Table Storage in Python and is part of the 'azure.data.tables' package library.