##// END OF EJS Templates
fixed bug when there was no dbfile, and dbmanage raise an exception
marcink -
r243:9d64df49 default
parent child Browse files
Show More
@@ -26,10 +26,12 b' class DbManage(object):'
26 engine = create_engine(dburi, echo=log_sql)
26 engine = create_engine(dburi, echo=log_sql)
27 init_model(engine)
27 init_model(engine)
28 self.sa = Session()
28 self.sa = Session()
29 self.db_exists = False
29
30
30 def check_for_db(self, override):
31 def check_for_db(self, override):
31 log.info('checking for exisiting db')
32 log.info('checking for exisiting db')
32 if os.path.isfile(jn(ROOT, self.dbname)):
33 if os.path.isfile(jn(ROOT, self.dbname)):
34 self.db_exists = True
33 log.info('database exisist')
35 log.info('database exisist')
34 if not override:
36 if not override:
35 raise Exception('database already exists')
37 raise Exception('database already exists')
@@ -41,6 +43,7 b' class DbManage(object):'
41 self.check_for_db(override)
43 self.check_for_db(override)
42 if override:
44 if override:
43 log.info("database exisist and it's going to be destroyed")
45 log.info("database exisist and it's going to be destroyed")
46 if self.db_exists:
44 os.remove(jn(ROOT, self.dbname))
47 os.remove(jn(ROOT, self.dbname))
45 Base.metadata.create_all(checkfirst=override)
48 Base.metadata.create_all(checkfirst=override)
46 log.info('Created tables for %s', self.dbname)
49 log.info('Created tables for %s', self.dbname)
General Comments 0
You need to be logged in to leave comments. Login now