def create_db(self): if self.args.db_url is None: self.args.db_url = self.DEFAULT_URL self.logger.info("Creating database ...") db = FannsMongoDb(self.args.db_url) db.open(create=True) if db.is_initialized(): self.logger.error("The database already exists and it is initialized") db.close() exit(-1) self.db = db return db
def open_db(self): if self.args.db_uri is None: self.args.db_uri = self.DEFAULT_URL self.logger.info("Opening database {} ...".format(self.args.db_uri)) db = FannsMongoDb(uri=self.args.db_uri) db.open() if not db.is_initialized(): self.logger.error("The database is not initialized") db.close() exit(-1) self.db = db return db