Преглед изворни кода

query to dataframe in InfluxdbHandler, added returning empty dataframe

tanja пре 3 година
родитељ
комит
f097f538ac
1 измењених фајлова са 8 додато и 1 уклоњено
  1. 8 1
      cdplib/db_handlers/InfluxdbHandler.py

+ 8 - 1
cdplib/db_handlers/InfluxdbHandler.py

@@ -82,8 +82,15 @@ class InfluxdbHandler:
         try:
             # result of the query is a defaultdict
             result = self.client.query(query)
+            
+            if len(list(result.values())) > 0:
 
-            return list(result.values())[0]
+                return list(result.values())[0]
+            
+            else:
+                
+                return pd.DataFrame()
+            
         except Exception as e:
             self._logger.log_and_raise_error(
                 ("Could not query to dataframe. "