admin.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:FeatureHub 作者: HDI-Project 项目源码 文件源码
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")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号