|
@@ -259,15 +259,18 @@ class MongodbHandler:
|
|
|
|
|
|
def query_data_and_generate_dataframe(self, collection_name: str, attribute: str = None,
|
|
def query_data_and_generate_dataframe(self, collection_name: str, attribute: str = None,
|
|
attribute_value: str = None, comparison_operator: str = '$eq',
|
|
attribute_value: str = None, comparison_operator: str = '$eq',
|
|
- index = None, return_as_dataframe: bool = True, return_id: bool = False):
|
|
|
|
|
|
+ index = None, return_as_dataframe: bool = True, return_id: bool = False, return_values: dict = None):
|
|
'''
|
|
'''
|
|
|
|
|
|
'''
|
|
'''
|
|
|
|
+ if return_values is None:
|
|
|
|
+ return_values = {'_id': return_id}
|
|
|
|
+
|
|
try:
|
|
try:
|
|
if attribute == None or attribute_value == None:
|
|
if attribute == None or attribute_value == None:
|
|
- data = self._database[collection_name].find({},{'_id': return_id})
|
|
|
|
|
|
+ data = self._database[collection_name].find({},return_value)
|
|
else:
|
|
else:
|
|
- data = self._database[collection_name].find({attribute: {comparison_operator: attribute_value}}, {'_id': return_id})
|
|
|
|
|
|
+ data = self._database[collection_name].find({attribute: {comparison_operator: attribute_value}}, return_value)
|
|
|
|
|
|
except Exception as error:
|
|
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))
|
|
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))
|
|
@@ -303,8 +306,8 @@ class MongodbHandler:
|
|
except Exception as error:
|
|
except Exception as error:
|
|
self._log.log_and_raise_error(('An error occured trying to convert mongo data into pd.Dataframe. \nError: {} ').format(error))
|
|
self._log.log_and_raise_error(('An error occured trying to convert mongo data into pd.Dataframe. \nError: {} ').format(error))
|
|
|
|
|
|
- def update_data_in_collection(self, query_label: str, query_value: str, update_label:str, update_value: str, collection_name:str):
|
|
|
|
- self._database[collection_name].update_one({query_label:query_value}, {"$set": {update_label: update_value}})
|
|
|
|
|
|
+ #def update_data_in_collection(self, query_label: str, query_value: str, update_label:str, update_value: str, collection_name:str):
|
|
|
|
+ # self._database[collection_name].update_one({query_label:query_value}, {"$set": {update_label: update_value}})
|
|
|
|
|
|
|
|
|
|
def push_data_into_collection(self, data: (dict, list, np.ndarray, pd.DataFrame, pd.Series),
|
|
def push_data_into_collection(self, data: (dict, list, np.ndarray, pd.DataFrame, pd.Series),
|