I have a Queue of items i need to perform some actions on, I’m done when the queue is empty. I’m trying to get the best way to check for an empty result. My query returns six columns, so when i select from the table, it returns to me an empty set with six columns.
Is there a flag or something i can set that would have the function return a None or something similar if the result set is empty?
I’m using len(result), i guess it works but i wanted to see if anyone else has any other or better suggestions? Thanks
Another idea is not checking if a result set is empty or has 0 rows. But this only works depending on what you are trying to do. For instance if you want to loop through the rows in a result set and do some action with each row then it is not necessary to check for an empty result set.
Here is an example:
result = system.db.runQuery(myquery)
for row in result:
print row["first column"]
print row["second column"]
...
In the above case it is not necessary to check for an empty result set because the looping code will not execute if the result set has 0 rows.