Beispiel #1
0
def delete_employer_by_id(id_):
    try:
        trans = Transaction()
        n = trans.query(Employer).filter(Employer.id == id_).delete()
        trans.commit()

        return ('ok', '', n)
    except Exception as e:
        return ('err', e.__class__.__name__, 0)
Beispiel #2
0
def update_employer(id_, req):
    try:
        trans = Transaction()
        n = trans.query(Employer).filter(Employer.id == id_).update(req)
        trans.commit()

        return ('ok', '', n)
    except IntegrityError as e:
        return ('err', e.__class__.__name__, 0)
    except Exception as e:
        return ('err', e.__class__.__name__, 0)
Beispiel #3
0
def create_employer(req):
    try:
        trans = Transaction()
        employer = Employer(**req)
        trans.add(employer)
        trans.commit()

        return ('ok', '', employer.id)
    except IntegrityError as e:
        return ('err', e.__class__.__name__, None)
    except Exception as e:
        return ('err', e.__class__.__name__, None)