1

I am trying to query Azure Table Storage using Python. An int32 datatype column doesn't return its value but returns something like this azure.storage.table.models.EntityProperty obj..... But, in case of string datatype columns, i am not facing any such issues. Could someone please help me ?

The column Pos in below script is an integer column in the table

queryfilter = "startDateTime gt datetime'%s' and temp eq '%s'" % (datefilter, temp)

task = table_service.query_entities(azureTable, filter=queryfilter)

for t in task: 
   print(t.Pos)
Sraw
  • 18,892
  • 11
  • 54
  • 87
AngiSen
  • 915
  • 4
  • 18
  • 41

2 Answers2

2

Looking at the documentation here: https://learn.microsoft.com/en-us/python/api/azure.cosmosdb.table.models.entityproperty?view=azure-python, can you try the following?

for t in task: print(t.Pos.value)
Gaurav Mantri
  • 128,066
  • 12
  • 206
  • 241
1

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).

The new library uses a similar TableEntity which is a key-value type inheriting from the Python dictionary, the value is the same EntityProperty. There are two ways to access entity properties. If the type is an Int32 (default integer type) or String they can be accessed by:

my_value = entity.my_key  # direct access
my_value = entity['my_key'] # same access pattern as a dict

If the EntityProperty is of type INT32 or BINARY then you will have to use the .value notation:

my_value = entity.my_key.value  # direct access
my_value = entity['my_key'].value # same access pattern as a dict

FYI I am a full-time engineer at Microsoft on the Azure SDK for Python team.

spkane31
  • 385
  • 2
  • 6