Using the IN operation in a Google App Engine query is limited to 30 items in the list per query, so I have to find a way to break up the list into multiple lists with a maximum of 30 items in each array, and query each sub array.
I’ve come up with a small solution to do this, but it’s very inelegant, and I’m not sure if this is the best way to do this. I’m new to Python, so I’m wondering how I might do this correctly or more elegantly?
I’m querying for User.query(User.email IN emails)
max_length = 30
iter_count = len(emails) / max_length
for i in range(iter_count):
min = i * max_length
max = (i + 1) * max_length
if min > len(emails):
break
if max > len(emails):
max = len(emails)
current_array = emails[min:max]
# query this array
1 Answer