Exemple #1
0
 def store_records(self):
     '''
     method to store each record into mongodb
     :return:
     '''
     json_data = File_Handle.read_json()
     csv_rec = File_Handle.Csv_read(json_data['path'])
     try:
         for each_record in csv_rec:
             if each_record not in self.db_config.find(
                     json_data['order_ID']):
                 MongoDB.insert_record(each_record)
     except Exception as e:
         return e
     else:
         return 'records inserted successfully'
Exemple #2
0
 def record_deletion(self):
     '''
     data op method to delete records
     '''
     try:
         deleted_records = MongoDB.delete_rec(self.db_config)
     except Exception as e:
         return e
     else:
         return deleted_records
Exemple #3
0
 def get_records(self):
     '''
     dta op method to record count
     '''
     try:
         record_count = MongoDB.db_config().find().count()
     except Exception as e:
         return e
     else:
         return record_count
Exemple #4
0
 def sorting_records(self):
     '''
     method to sort record
     '''
     json_data = File_Handle.read_json()
     try:
         sorting_ascending_order = MongoDB.sort(self.db_config,
                                                json_data['field'])
     except Exception as e:
         return e
     else:
         return sorting_ascending_order
Exemple #5
0
 def updating_records(self):
     '''
     data operation method to update records
     '''
     json_data = File_Handle.read_json()
     try:
         update_result = MongoDB.update_records(self.db_config,
                                                json_data['query'],
                                                json_data['value'])
     except Exception as e:
         return e
     else:
         return update_result
Exemple #6
0
def MongoDBRecovery(dbpath):
    return MongoDB(settings.MONGOD_PORT, 'mongod.recovery', dbpath)
Exemple #7
0
 def get_command(self):
     return MongoDB.get_command(self) + ['--master']
Exemple #8
0
 def __init__(self, dbpath):
     MongoDB.__init__(self, settings.MONGOD_REPLICATION_PORT,
                      'mongod.replication', dbpath)
Exemple #9
0
 def __init__(self):
     self.db_config = MongoDB.db_config()
Exemple #10
0
 def get_command(self):
     return MongoDB.get_command(self) + ["--master"]
Exemple #11
0
 def __init__(self, dbpath):
     MongoDB.__init__(self, settings.MONGOD_REPLICATION_PORT, "mongod.replication", dbpath)