Exemplo n.º 1
0
def insert_application(app):
    try:
        db.session.add(app)
        db.session.commit()
    except Exception as e:
        raise Insert2SQLError("insert application to sql error",
                              e.orig.args[-1])
Exemplo n.º 2
0
def insert_operators(operators):
    try:
        for op in operators:
            db.session.add(op)
        db.session.commit()
    except Exception as e:
        raise Insert2SQLError("Insert operator to sql error", e.orig.args[-1])
Exemplo n.º 3
0
def replace_all_operators(operators):
    try:
        db.session.query(Operator).delete()
        for op in operators:
            db.session.add(op)
        db.session.commit()
    except Exception as e:
        print(e)
        raise Insert2SQLError("Insert operator to sql error", e.orig.args[-1])
Exemplo n.º 4
0
def insert_fields(fields):
    try:
        exist, name = fields_exist_check(fields)
        if exist:
            raise ExistError(f"field <{name}> had exist", "")
        ids = []
        for field in fields:
            db.session.add(field)
            db.session.flush()
            ids.append(field.id)
        db.session.commit()
        return ids
    except Exception as e:
        if isinstance(e, ExistError):
            raise e
        raise Insert2SQLError("insert fields to sql error", e)
Exemplo n.º 5
0
def add_mapping_data(mapping):
    try:
        db.session.add(mapping)
        db.session.commit()
    except Exception as e:
        raise Insert2SQLError("insert mapping to sql error", e.orig.args[-1])
Exemplo n.º 6
0
def insert_pipeline(p):
    try:
        db.session.add(p)
        db.session.commit()
    except Exception as e:
        raise Insert2SQLError("insert to sql error", e.orig.args[-1])