I have a list in python which is product of a query to Google’s Datastore, the list looks like this:
JavaScript
x
2
1
[<Entity('User', 1111) {'refreshToken': 'xxx', 'firstName': 'Bill', 'lastName': 'Last', 'accessToken': 'xxx', 'idToken': 'xxx', 'email': 'the_email'}>]
2
I need to extract the ID of the entity which is 1111
. I’ve tried the following with no success thus far:
JavaScript
1
6
1
result = list(query.fetch())
2
print(result[0][0]) #fails
3
print(result[0].Entity) #fails
4
print(result[0]['User']) #fails
5
print(result['User']) #fails
6
Any idea how I might be able to retrieve the ID value?
Advertisement
Answer
JavaScript
1
3
1
entity = result[0]
2
print(entity.id)
3