Ejemplo n.º 1
0
Archivo: 45.py Proyecto: mestaki/qiita
with TRN:
    # a few notes: just getting the preps with duplicated values; ignoring
    # column 'sample_id' and tables 'study_sample', 'prep_template',
    # 'prep_template_sample'
    sql = """SELECT table_name, array_agg(column_name::text)
                FROM information_schema.columns
                WHERE column_name IN %s
                    AND column_name != 'sample_id'
                    AND table_name LIKE 'prep_%%'
                    AND table_name NOT IN (
                        'prep_template', 'prep_template_sample')
                GROUP BY table_name"""
    # note that we are looking for those columns with duplicated names in
    # the headers
    headers = set(PrepTemplate.metadata_headers()) & \
        set(SampleTemplate.metadata_headers())

    if headers:
        TRN.add(sql, [tuple(headers)])
        overlapping = dict(TRN.execute_fetchindex())
    else:
        overlapping = None

if overlapping is not None:
    # finding actual duplicates
    for table_name, cols in overlapping.items():
        # leaving print so when we patch in the main system we know that
        # nothing was renamed or deal with that
        print(table_name)
        with TRN:
Ejemplo n.º 2
0
with TRN:
    # a few notes: just getting the preps with duplicated values; ignoring
    # column 'sample_id' and tables 'study_sample', 'prep_template',
    # 'prep_template_sample'
    sql = """SELECT table_name, array_agg(column_name::text)
                FROM information_schema.columns
                WHERE column_name IN %s
                    AND column_name != 'sample_id'
                    AND table_name LIKE 'prep_%%'
                    AND table_name NOT IN (
                        'prep_template', 'prep_template_sample')
                GROUP BY table_name"""
    # note that we are looking for those columns with duplicated names in
    # the headers
    headers = set(PrepTemplate.metadata_headers()) & \
        set(SampleTemplate.metadata_headers())

    if headers:
        TRN.add(sql, [tuple(headers)])
        overlapping = dict(TRN.execute_fetchindex())
    else:
        overlapping = None

if overlapping is not None:
    # finding actual duplicates
    for table_name, cols in viewitems(overlapping):
        # leaving print so when we patch in the main system we know that
        # nothing was renamed or deal with that
        print table_name
        with TRN: