# HG changeset patch # User Marcin Kuzminski # Date 2010-06-01 22:06:48 # Node ID 9d64df49024801fc618e913bc48dc1f91f1488d0 # Parent 5da4ef115006915c74c48cfc38890876d3d8712f fixed bug when there was no dbfile, and dbmanage raise an exception diff --git a/pylons_app/lib/db_manage.py b/pylons_app/lib/db_manage.py --- a/pylons_app/lib/db_manage.py +++ b/pylons_app/lib/db_manage.py @@ -26,10 +26,12 @@ class DbManage(object): engine = create_engine(dburi, echo=log_sql) init_model(engine) self.sa = Session() + self.db_exists = False def check_for_db(self, override): log.info('checking for exisiting db') if os.path.isfile(jn(ROOT, self.dbname)): + self.db_exists = True log.info('database exisist') if not override: raise Exception('database already exists') @@ -41,7 +43,8 @@ class DbManage(object): self.check_for_db(override) if override: log.info("database exisist and it's going to be destroyed") - os.remove(jn(ROOT, self.dbname)) + if self.db_exists: + os.remove(jn(ROOT, self.dbname)) Base.metadata.create_all(checkfirst=override) log.info('Created tables for %s', self.dbname)