Ejemplo n.º 1
0
def create_metadata_from_user_inputs(session, tablename, user_inputs):
    lmds = []
    for user_input in user_inputs:
        if user_input.get('deleted', False):
            continue

        if 'id' in user_input:
            lmd = session.query(LMD).get(user_input['id'])
        else:
            lmd = LMD()

        lmd.tname = tablename
        lmd.col_name = user_input['col_name']
        lmd.loc_type = user_input['loc_type']
        lmd.extract_type = ExtractType.FMT
        lmd.fmt = user_input['format'].strip()
        lmd.source = LocSource.USER


        lmds.append(lmd)
    return lmds