def drop_database(connection, dbname): try: logger.info('Drop database `%s`', dbname) connection.run(r.db_drop(dbname)) logger.info('Done.') except r.ReqlOpFailedError: raise exceptions.DatabaseDoesNotExist('Database `{}` does not exist'.format(dbname))
def drop(assume_yes=False): conn = get_conn() dbname = bigchaindb.config['database']['name'] if assume_yes: response = 'y' else: response = input( 'Do you want to drop `{}` database? [y/n]: '.format(dbname)) if response == 'y': try: logger.info('Drop database `%s`', dbname) r.db_drop(dbname).run(conn) logger.info('Done.') except r.ReqlOpFailedError: raise exceptions.DatabaseDoesNotExist( 'Database `{}` does not exist'.format(dbname)) else: logger.info('Drop aborted')