I'm using the CosmosDB noSQL API and I feel like I'm not doing it right. The methods in the container class all return these iterator objects, which only have one method: next().
I need to get a list of records out of my container, and my only thought is to do this:
def to_list(iterator):
list = []
for i in range(0, 99):
try:
list.append(iterator.next())
except:
break
return list
This works, but it feels bad. Is this going to be a performance problem? Does the Iterator class actually have all of my data in it? Like if I do the above with an iterator I get back, am I making 1 query to cosmos or 100?
I found this article which is using the methods in azure.cosmos.cosmos_client instead, but you still end up looping over everything. Is this normal, should I be using sqlalchemy or something instead?
What's best practice for how to talk to CosmosDB using python?