コード例 #1
0
def create_mock():
    form = CreateMockForm().execute_validate()
    result = Mock.insert(form)
    if result:
        return Success()
    else:
        return DatabaseError()
コード例 #2
0
def update_mock(id):
    form = CreateMockForm().execute_validate()
    result = Mock.update_mock(id, form)
    if result:
        return Success()
    else:
        return DatabaseError()
コード例 #3
0
def register():
    form = UserRegisterForm().execute_validate()
    result = User.register_by_email(form['email'], form['password'])
    if result:
        return Success()
    else:
        return DatabaseError()
コード例 #4
0
def update_project(id):
    form = CreateProjectForm().execute_validate()
    result = Project.update_project(id, form)
    if result:
        return Success()
    else:
        return DatabaseError()
コード例 #5
0
def create_project():
    form = CreateProjectForm().execute_validate()
    result = Project.insert(form['name'], form['desc'])
    if result:
        return Success()
    else:
        return DatabaseError()
コード例 #6
0
 def auto_commit(self):
     try:
         yield
         self.session.commit()
     except Exception as e:
         db.session.rollback()
         # raise e
         print(e)
         raise DatabaseError()
コード例 #7
0
 def delete(cls, key, value):
     table_name = cls.__name__.lower()
     sql = "update {} set deleted=1 where {} = {}".format(table_name, key, value)
     if not isinstance(value, int):
         sql = "update {} set deleted=1 where {} = '{}'".format(table_name, key, value)
     try:
         with db.auto_commit():
             db.session.execute(sql)
     except ProgrammingError as e:
         print(e)
         return DatabaseError()