diff --git a/bigchaindb/db/utils.py b/bigchaindb/db/utils.py index 55ad7c03..d72a4f04 100644 --- a/bigchaindb/db/utils.py +++ b/bigchaindb/db/utils.py @@ -1,17 +1,13 @@ """Utils to initialize and drop the database.""" import logging - import rethinkdb as r - import bigchaindb +from bigchaindb import exceptions logger = logging.getLogger(__name__) -class DatabaseAlreadyExistsException(Exception): - pass - def get_conn(): '''Get the connection to the database.''' @@ -24,7 +20,7 @@ def init(): dbname = bigchaindb.config['database']['name'] if r.db_list().contains(dbname).run(conn): - raise DatabaseAlreadyExistsException('Database `{}` already exists'.format(dbname)) + raise exceptions.DatabaseAlreadyExistsException('Database `{}` already exists'.format(dbname)) logger.info('Create:') logger.info(' - database `%s`', dbname) diff --git a/bigchaindb/exceptions.py b/bigchaindb/exceptions.py index eb87ca25..07cb0155 100644 --- a/bigchaindb/exceptions.py +++ b/bigchaindb/exceptions.py @@ -19,3 +19,6 @@ class InvalidHash(Exception): class InvalidSignature(Exception): """Raised if there was an error checking the signature for a particular operation""" +class DatabaseAlreadyExistsException(Exception): + """Raised when trying to create the database but the db is already there""" +