On object creation, when connection to server is established, is now implemented check if database has all tables as it should have.
import collections
import utils
import collections
import utils
from conf import conf
def __git_describe__():
from conf import conf
def __git_describe__():
host = conf.db_host,
port = conf.db_port
)
host = conf.db_host,
port = conf.db_port
)
+ # check if tables are present
+ tables = ('toolsgit', 'configurations', 'measure')
+ for tab in tables:
+ val = self.db.prepare("""SELECT COUNT(*) FROM pg_class
+ WHERE relname = $1""")(tab)[0][0]
+ if val < 1:
+ raise exceptions.DatabaseUninitialized()
def check_toolsgit(self):
"Return id of toolsgit row. If missing, it is inserted"
def check_toolsgit(self):
"Return id of toolsgit row. If missing, it is inserted"
def __str__(self):
return "Process failed: " + str(self.process) + \
" with return code: " + str(self.returncode)
def __str__(self):
return "Process failed: " + str(self.process) + \
" with return code: " + str(self.returncode)
+
+class DatabaseUninitialized(Exception):
+ def __str__(self):
+ return "Database seems to be uninitialized."
solution.generate()
except exceptions.NoSolution:
pass
solution.generate()
except exceptions.NoSolution:
pass
+ # check if database is initialized
+ database.database()
def base():
print('Initialize base...')
def base():
print('Initialize base...')