瀏覽代碼

Investigating strange error

ogert 4 年之前
父節點
當前提交
15533df33b
共有 1 個文件被更改,包括 6 次插入5 次删除
  1. 6 5
      cdplib/db_handlers/MongodbHandler.py

+ 6 - 5
cdplib/db_handlers/MongodbHandler.py

@@ -281,17 +281,18 @@ class MongodbHandler:
 
         try:
             if attribute == None or attribute_value == None:
-                data = self._database[collection_name].find({},return_values)
+                query = {}
             else:
-                data = self._database[collection_name].find({attribute: {comparison_operator: attribute_value}}, return_values)
+                query = {attribute: {comparison_operator: attribute_value}}
+
+            data = self._database[collection_name].find(query, return_values)
 
         except Exception as error:
             self._log.log_and_raise_error(('An error occured trying to query data from {}, with query {}: {}:{}. \nError:{}').format(collection_name, attribute, comparison_operator, attribute_value, error))
             return None
 
-        #print(data[0])
-        #print(len(data[0]))
-        if True: #data.retrieved() != 0:
+
+        if data.collection.count_documents(query) != 0:
             if return_as_dataframe:
                 return self.convert_mongo_data_into_dataframe(data, index, collection_name)
             else: