mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
DB result iteration fix on empty result
get_table_json would throw exceptions when trying to iterate over a NONE result, ie SQL query returned empty result.
This commit is contained in:
@@ -199,8 +199,12 @@ def get_table_json(sql, sql_query):
|
||||
mylog('verbose', ['[Database] - SQL ERROR: ', e])
|
||||
return json_obj({}, []) # return empty object
|
||||
|
||||
result = {"data": [row_to_json(column_names, row) for row in rows]}
|
||||
return json_obj(result, column_names)
|
||||
if (rows):
|
||||
result = {"data": [row_to_json(column_names, row) for row in rows]}
|
||||
return json_obj(result, column_names)
|
||||
else:
|
||||
# the SQL query returned no rows
|
||||
return json_obj({}, []) # return empty object
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user