What is table storage

Azure Table storage is a way to store structured data in the cloud NoSQL Data services , Provide keys through unstructured design / Property store .  Because table storage has no fixed data structure requirements , So it's easy to adapt data to storage as application requirements evolve .Azure Table storage can store large amounts of structured data .  The service is a NoSQL data storage , from Azure Verified calls inside and outside the cloud . Azure Tables are best for storing structured, non relational data .  Common uses of table storage include :

  • Storage TB Structured data of the order of magnitude , Can be Web Scale applications provide services
  • Storage does not require complex joins 、 Foreign keys or stored procedures , And it can be denormalized to achieve fast access to data sets
  • Use clustered indexes to quickly query data
  • Use OData The protocol and LINQ Inquiry and WCF Data services .NET Library access data

Table storage can be used to store and query large structured non relational datasets , And the table will expand as the demand increases . The table store contains the following components :

( The content comes from Azure: https://docs.azure.cn/zh-cn/cosmos-db/table-storage-overview

Problem description

Is there a Python module It can be directly to Storage Account Table( Table is stored ) To operate ? yes , we have . Stored in the query table Python After the documents , It USES Python module On cosmosDB equally . Introduce... Into your code azure.cosmosdb.table that will do .

from azure.cosmosdb.table.tableservice import TableService
from azure.cosmosdb.table.models import Entity

Use PIP install azure-cosmosdb-table modular . stay VS Code In the implementation of : python -m pip install azure-cosmosdb-table

Operation code

adopt Python Start using Azure Table storage and Azure Cosmos DB surface API

This example shows how to use the common Azure Table storage scheme be used for Python Of Azure Cosmos DB surface SDK.  The SDK The name of indicates that it is suitable for Azure Cosmos DB In combination with , But it's time to SDK It is suitable for Azure Cosmos DB In combination with , It's also suitable for Azure Table storage is used with , It's just that each service has a unique endpoint .  This article USES the Python Examples explore these solutions , To demonstrate how to :

  • Create and delete tables
  • Insert and query entities
  • Modify the entity

Source:https://docs.azure.cn/zh-cn/cosmos-db/table-storage-how-to-use-python?toc=https%3A%2F%2Fdocs.azure.cn%2Fzh-cn%2Fstorage%2Ftables%2Ftoc.json&bc=https%3A%2F%2Fdocs.azure.cn%2Fzh-cn%2Fbread%2Ftoc.json

Python cosmosdb table The module contains all the atomic operations on the table . The following code example contains :

  • Create table :create_table
  • Add entity to table :insert_entity
  • Update entity :update_entity / insert_or_replace_entity
  • Modify multiple entities : with table_service.batch(tablename) as batch
  • Query entities : get_entity
  • Query a set of entities : table_service.query_entities(tablename, filter="PartitionKey eq 'tasksSeattle'")
  • Query part of the entity properties :table_service.query_entities(tablename, filter="PartitionKey eq 'tasksSeattle'", select='description')
  • Delete entities :delete_entity
  • Delete table :delete_table

All the code :

from azure.cosmosdb.table.tableservice import TableService
from azure.cosmosdb.table.models import Entity ## Connect to Azure Table service , account_key The content is in Azure Storage Account From the portal of (Storage Account --> Access Keys)
table_service = TableService(account_name='you storage account name', account_key='your storage account key', endpoint_suffix='core.chinacloudapi.cn') ## Create table
tablename='tasktable2'
table_service.create_table(tablename) ## Add entity to table
task = {'PartitionKey': 'tasksSeattle', 'RowKey': '001',
'description': 'Take out the trash', 'priority': 200}
table_service.insert_entity(tablename, task) ## Same way:
# task = Entity()
# task.PartitionKey = 'tasksSeattle'
# task.RowKey = '002'
# task.description = 'Wash the car'
# task.priority = 100
# table_service.insert_entity(tablename, task) ## Update entity
print('## Update entity ')
task = {'PartitionKey': 'tasksSeattle', 'RowKey': '001',
'description': 'Take out the garbage', 'priority': 250}
table_service.update_entity(tablename, task) ## If the entity to be updated does not exist , The update operation will fail . If you want to store entities ( Whether it exists or not )
print('## If the entity to be updated does not exist , The update operation will fail . If you want to store entities ( Whether it exists or not )')
# Replace the entity created earlier
task = {'PartitionKey': 'tasksSeattle', 'RowKey': '001',
'description': 'Take out the garbage again', 'priority': 250}
table_service.insert_or_replace_entity(tablename, task) # Insert a new entity
task = {'PartitionKey': 'tasksSeattle', 'RowKey': '003',
'description': 'Buy detergent', 'priority': 300}
table_service.insert_or_replace_entity(tablename, task) ## Modify multiple entities
print('## Modify multiple entities ')
task006 = {'PartitionKey': 'tasksSeattle', 'RowKey': '006',
'description': 'Go grocery shopping', 'priority': 400}
task007 = {'PartitionKey': 'tasksSeattle', 'RowKey': '007',"MyAddColumn":"you know, thing changed, life goes on.",
'description': 'Clean the bathroom', 'priority': 100} with table_service.batch(tablename) as batch:
batch.insert_entity(task006)
batch.insert_entity(task007) ## Query entry / Entity
print('## Query entry / Entity ')
task = table_service.get_entity(tablename, 'tasksSeattle', '001')
print(task.description)
print(task.priority) ## Query a set of items
print('## Query a set of items ')
tasks = table_service.query_entities(
tablename, filter="PartitionKey eq 'tasksSeattle'")
for task in tasks:
print(task.description)
print(task.priority) ## Query part of the entity properties
print('## Query part of the entity properties ')
tasks = table_service.query_entities(
tablename, filter="PartitionKey eq 'tasksSeattle'", select='description')
for task in tasks:
print(task.description) # ## Delete entry / Entity
# print('## Delete entry / Entity ')
# table_service.delete_entity(tablename, 'tasksSeattle', '001') # ## Delete table
# print('## Delete table ')
# table_service.delete_table(tablename)

Execution results :

Reference documents

What is? Azure Table is stored ?:https://docs.azure.cn/zh-cn/storage/tables/table-storage-overview

adopt Python Start using Azure Table storage and Azure Cosmos DB surface API: https://docs.azure.cn/zh-cn/cosmos-db/table-storage-how-to-use-python?toc=https%3A%2F%2Fdocs.azure.cn%2Fzh-cn%2Fstorage%2Ftables%2Ftoc.json&bc=https%3A%2F%2Fdocs.azure.cn%2Fzh-cn%2Fbread%2Ftoc.json

TableService Class: https://docs.microsoft.com/en-us/python/api/azure-cosmosdb-table/azure.cosmosdb.table.tableservice.tableservice?preserve-view=true&view=azure-python#insert-entity-table-name--entity--timeout-none-

【Azure Storage service 】Python modular (azure.cosmosdb.table) Store directly to the table (Storage Account Table) Do more related articles about operation examples

  1. Azure Backup (3) Use Azure Backup service , Backup Azure virtual machine

    <Windows Azure Platform List of articles > This article will introduce , How to use Azure Backup service , Backup Azure virtual machine . Let's pre create 2 platform Windows VM ( Name it LeiVM00 ...

  2. wp8.1 Study16: Of the network Use Azure Mobile services and utilization Azure Push notification service

    One .WP8.1 About the Internet API WP8.1 The comparison with other platforms is as follows : Two .Azure Mobile services Premise : Azure Mobile services allow users to store their data in the cloud , So as to facilitate the user's App Data sharing on different platforms . 1 ...

  3. thorough Android Media storage services ( One ):APP Interaction with media storage services

    brief introduction : This article describes how to Android in , Developer's APP How to use media storage service ( contain MediaScanner.MediaProvider And the analysis of media information ), Including how to APP New or modified text ...

  4. Microsoft Azure Cloud storage service concept

    This paper includes the following contents : What is? Azure Cloud storage services ? Cloud storage service classification The advantages of cloud storage services What is? Azure Cloud storage services ? Azure Cloud storage services can be said to be Azure The most important thing in the world SAAS Yes . stay Azur ...

  5. To announce the official release of Windows Azure Mobile services 、 Website and continuous service innovation

    We strive to innovate , Provide diverse platforms for developers to build the best cloud applications and provide them to customers all over the world in the first time . Many new applications belong to " Modern applications ", That is, always based on Web, And can be carried out through a variety of mobile devices ...

  6. Windows Azure Storage (18) Use HTML5 Portal Of Azure CDN service

    <Windows Azure Platform List of articles > Update:2015-04-15 If the readers use the products operated by century Internet in China Azure China service , Please refer to the author's documentation :Azu ...

  7. Azure Backup (2) Azure Backup service

    <Windows Azure Platform List of articles > This paper introduces the operation and maintenance of century Internet in China Azure China. This paper introduces Azure The management interface is Classic Model, website :h ...

  8. Azure New lock for media service , Safer and more convenient , Please put away the new key !

    I don't know how many people have replaced their door locks with digital fingerprint locks ? Traditional door locks that have been used for hundreds and thousands of years , With the help of technology, it's no doubt more convenient , No keys , It can also be controlled and operated remotely , most important of all , Finally, don't worry 「 Yiguo (luǒ) the 」 Go out and throw the garbage , wind ...

  9. To announce the official release of Azure Media services, content protection services

    Mingfei Yan Azure Media services Project Manager We are very happy to announce that Azure Media services, content protection services . This includes Microsoft PlayReady Licensing services and AES Plaintext key delivery service ! Besides ...

  10. Deploy microservices to Azure Kubernetes service (AKS) practice

    This article is about <.NET Tutorial - Deploy a microservice to Azure> Translation and practice of . Entry level pit practice ,k8s Boss, please avoid , So as not to waste your precious time . Introduce ...

Random recommendation

  1. Jenkins stay Windows System dotnet Platform continuous integration

            I wrote an article before in CentOS Build on .net Automated compilation environment , Today's article is about Windows Platform environment .        Jenkins It's an open source software project , It aims to provide an open and easy-to-use software platform ...

  2. sublime text 3 Usage method

    1.Package Control  Installing a plug-in 2.Material Theme  The theme 3.Emmet Automatically HTML label 4.Snippets JS Automatic clips 5.Advance newfile Under the folder ...

  3. JavaScript Common array operation function and usage in

    JavaScript Common array operation function and usage in I wrote a post yesterday , Here's a summary of the common JavaScript String operation function and usage in . It's just time today , Also go to JavaScript In the common array operation function and Usage Summary ...

  4. Encryption and ssl Details of the mechanism

    1.1 Background knowledge Symmetric encryption : Encryption and decryption use the same key , Fast encryption and decryption . As the number of people increases , The number of keys has skyrocketed n(n-1)/2 Asymmetric encryption : Encryption and decryption using public private key pairing , Slow speed . The public key is extracted from the private key , Generally take the other party's public key encryption to guarantee ...

  5. SQL Optimize it 【 Type conversion 】

    DBA In our daily work SQL Optimization takes up most of the time , Is usually SQL Statement performance problems or schema There's something wrong with the design , Recently I encountered a type conversion problem , So share it here , No more nonsense , Build a table to test directly . mysql), key ...

  6. Use prototype Object defines class members

    Use prototype Object defines class members. The previous section describes the implementation mechanism of the class and the implementation of the constructor , Now let's introduce another mechanism for adding members to a class :prototype object . When new One function when , Members of the object are automatically assigned to ...

  7. Xcode7 Use NSURLSession send out HTTP Request an error

    http://blog.csdn.net/chenyong05314/article/details/46721205

  8. @( Report errors )could not find the main class, Program will exit( resolved )

    original text  @( Report errors )could not find the main class, Program will exit( resolved )      ( I'm sorry , If you want to see the picture or the text more clearly , You can ...

  9. Windows Azure Introductory teaching series ( One ): Create the first one WebRole Program

    original text  Windows Azure Introductory teaching series ( One ): Create the first one WebRole Program In the first lesson , We will learn how to be in Visual Studio 2008 SP1 Create a WebRole Program (C# Language ...

  10. Linux Static library &amp; Dynamic library call

    1. What is kuzai windows The platform and linux There are a lot of Libraries under the platform . Essentially, a library is a binary form of executable code , Can be loaded into memory by the operating system for execution . because windows and linux Different in nature , So the binary of the two libraries is not ...