def __init__(self, problem=None, database="featurehub"):
"""Create the ORMManager and connect to DB.
If problem name is given, load it.
Parameters
----------
problem : str, optional (default=None)
Name of problem
database : str, optional (default="featurehub")
Name of database within DBMS.
"""
self.__orm = ORMManager(database)
if not database_exists(self.__orm.engine.url):
print("database {} does not seem to exist.".format(database))
print("You might want to create it by calling set_up method")
elif problem:
try:
with self.__orm.session_scope() as session:
problem = session.query(Problem)\
.filter(Problem.name == problem).one()
self.__problemid = problem.id
except NoResultFound:
print("WARNING: Problem {} does not exist!".format(problem))
print("You might want to create it by calling create_problem"
" method")
评论列表
文章目录