Ejemplo n.º 1
0
def _add_sql_columns_for_table(sql_table,code):
    labels = mongoutils.get_labelset()
    table_labels = labels['tables'][code]
    if table_labels['name'].find('AVERAGE') != -1 or table_labels['name'].find('MEDIAN') != -1:
        col_type = Float
    else:
        col_type = Integer
    for label in sorted(table_labels['labels']):
        sql_table.append_column(Column(label, col_type(), nullable=False))
Ejemplo n.º 2
0
def _add_sql_columns_for_table(sql_table, code):
    labels = mongoutils.get_labelset()
    table_labels = labels['tables'][code]
    if table_labels['name'].find('AVERAGE') != -1 or table_labels['name'].find(
            'MEDIAN') != -1:
        col_type = Float
    else:
        col_type = Integer
    for label in sorted(table_labels['labels']):
        sql_table.append_column(Column(label, col_type(), nullable=False))
Ejemplo n.º 3
0
def generate_views_by_table(table_codes=None):
    labels = mongoutils.get_labelset()

    statements = []
    if table_codes is None:
        table_codes = []
        for f in SF1_FILE_SEGMENTS[1:]:
            table_codes.extend(f)

    statements = []
    for table_code in table_codes:
        table_name = _table_name_for_number(FILE_NUMBER_BY_TABLE_CODE[table_code])
        columns = ['"%s"' % x[0] for x in LINKING_COLUMNS]
        for label in sorted(labels['tables'][table_code]['labels']):
            columns.append('"%s"' % label)

        columns = ',\n'.join(columns)
        statements.append('CREATE VIEW sf1_%s as SELECT %s from %s;' % (table_code,columns,table_name))
    
    return "\n\n".join(statements)
Ejemplo n.º 4
0
def generate_views_by_table(table_codes=None):
    labels = mongoutils.get_labelset()

    statements = []
    if table_codes is None:
        table_codes = []
        for f in SF1_FILE_SEGMENTS[1:]:
            table_codes.extend(f)

    statements = []
    for table_code in table_codes:
        table_name = _table_name_for_number(
            FILE_NUMBER_BY_TABLE_CODE[table_code])
        columns = ['"%s"' % x[0] for x in LINKING_COLUMNS]
        for label in sorted(labels['tables'][table_code]['labels']):
            columns.append('"%s"' % label)

        columns = ',\n'.join(columns)
        statements.append('CREATE VIEW sf1_%s as SELECT %s from %s;' %
                          (table_code, columns, table_name))

    return "\n\n".join(statements)