Azure Table Storage Vs CosmosDB With Python


Answer :

The Azure CosmosDB Table SDK IS Azure Storage Tables SDK. Re-branding is part of some re-org inside Microsoft, but this is the same code and same endpoint, same everything.

Storage SDK was one big client, it was split into Table/Queue/Blog/Files packages, in order to give ownership of Table to CosmosDB team.

https://docs.microsoft.com/en-us/azure/cosmos-db/table-support

The new Azure Cosmos DB Python SDK is the only SDK that supports Azure Table storage in Python. This SDK connects with both Azure Table storage and Azure Cosmos DB Table API.

You can also compare the code, you'll see:

  • https://github.com/Azure/azure-storage-python/tree/v0.36.0/azure/storage/table
  • https://github.com/Azure/azure-cosmosdb-python/tree/master/azure-cosmosdb-table/azure/cosmosdb/table

(I work at MS in the Azure SDK for Python team)


Azure Table Storage has a new python library in preview release that is available for installation via pip. To install use the following pip command

pip install azure-data-tables 

This SDK is able to target either a Tables or Cosmos endpoint (albeit there are known issues with Cosmos).

For your use case of querying an Azure Table Storage account, there's two query methods.

Querying a single table:

from azure.data.tables import TableClient  table_client = TableClient.from_connection_string(conn_str, table_name="myTableName") query_filter = "RowKey eq 'row_key_5'" for entity in table_client.query_entities(filter=query_filter):     print(entity) 

Querying a storage account for tables:

from azure.data.tables import TableServiceClient  table_service_client = TableServiceClient.from_connection_string(conn_str, table_name="myTableName") query_filter = "TableName eq 'myTable'" for table in table_service_client .query_entities(filter=query_filter):     print(table.table_name) 

For more samples on the library check out the samples hosted on the Azure GitHub Repository.

(FYI I work at Microsoft on the Azure SDK for Python team)


Comments

Popular posts from this blog

Are Regular VACUUM ANALYZE Still Recommended Under 9.1?

Can Feynman Diagrams Be Used To Represent Any Perturbation Theory?