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)
4
  • where is your code? Commented Apr 24, 2018 at 2:15
  • Hi Sraw, script added Commented Apr 24, 2018 at 2:19
  • You could modify azureTable to 'azureTable',then have a try. Commented Apr 24, 2018 at 2:35
  • Hi Joy, the above script works for all other columns of string type from azureTable except the column Pos of int datatype. azureTable is a parameter passed while querying. I changed it with quotes but no luck Commented Apr 24, 2018 at 2:38

2 Answers 2

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)
Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.