X-Git-Url: http://gitweb.michael.orlitzky.com/?p=dead%2Fcensus-tools.git;a=blobdiff_plain;f=src%2FCensus.py;h=0f8d23473144d38602e3094797de3f44cd9b05fb;hp=63f69aaccaadf355b7d1b82414841e1d2839111b;hb=73a63cfdfdc7ea6db01572d5f76f1e0e7a16e37f;hpb=c7072bed9da48e659ffd023e7b974d5335297f44 diff --git a/src/Census.py b/src/Census.py index 63f69aa..0f8d234 100644 --- a/src/Census.py +++ b/src/Census.py @@ -46,11 +46,12 @@ class Database: cursor.execute(query, sql_params) rows = cursor.fetchall() cursor.close() - - if len(rows) > 0: + + # SQL queries that return no results get returned as [[None]]. + if rows[0][0] != None: return rows[0][0] else: - return None + return 0 def find_contained_population(self, well_known_text): @@ -112,10 +113,11 @@ class Database: rows = cursor.fetchall() cursor.close() - if (len(rows) > 0): + # SQL queries that return no results get returned as [[None]]. + if rows[0][0] != None: return rows[0][0] else: - return None + return 0 @@ -137,8 +139,7 @@ class Database: rows = cursor.fetchall() cursor.close() - if len(rows) > 0: - return rows[0][0] - else: - return None + # Just pass on the None if that's what we got from the + # database. + return rows[0][0]