How do I know if the results of my query, either using the Query interface or the GqlQuery interface, returned null results? Does a .get() null result use an error? If so, what's the best way to handle this?
.get()
when doing get (), if there are no results, you will have an object containing None
I usually do
result = query.get() if result is None: #do the following
or if you want to check that it is not there, then
if result is not None: #do the following
If the query returns no results, it fetch() returns an empty list [] and get() returnsNone
fetch()
[]
get()
None
you can use the following anyway:
if result: #handle the result else: #no results were returned