skip to Main Content

I am querying an Azure Data Table using Python:

# create azure table storage client
table_client = TableClient.from_connection_string(conn_str=key1, table_name="Table")

# query table
entities = table_client.query_entities(f"Timestamp ge datetime'{start_date}' and Timestamp le datetime'{end_date}'")

entity_list = []
for entity in entities:
    entity_list.append(entity)

Everything works as expected, except my result does not contain the Timestamp field.

How am I able to include the Timestamp in the query result?

2

Answers


  1. Chosen as BEST ANSWER

    For anyone coming back to this question in the future, a solution is to fetch the timestamp from the entity metadata:

    # create azure table storage client
    table_client = TableClient.from_connection_string(conn_str=key1, table_name="Table")
    
    # query table
    entities = table_client.query_entities(f"Timestamp ge datetime'{start_date}' and Timestamp le datetime'{end_date}'")
    
    entity_list = []
    for entity in entities:
        timestamp = entity._metadata["timestamp"]
        entity_list.append(entity)
    

  2. Looking at the SDK source code here, it looks the SDK is not including the Timestamp property in the resulting entity. The code is setting the PartitionKey (line 168) and RowKey (line 173) properties but not the Timestamp property.

    I believe your best bet would be to raise an issue here: https://github.com/Azure/azure-sdk-for-python/issues and ask the team to include this property in the resulting entity.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search