Project

General

Profile

« Previous | Next » 

Revision 4926

csv2db: Add any row_num column after creating the table, so it does not interfere with row widths when using COPY FROM without explicit column names

View differences:

csv2db
69 69
        def esc_name(name): return db.esc_name(name)
70 70
        
71 71
        typed_cols = [sql_gen.TypedCol(v, 'text') for v in col_names]
72
        if has_row_num:
73
            typed_cols.append(sql_gen.TypedCol('row_num', 'serial',
74
                nullable=False))
75 72
        
76 73
        log('Creating table')
77
        sql.create_table(db, table, typed_cols, has_pkey=has_row_num,
74
        sql.create_table(db, table, typed_cols, has_pkey=False,
78 75
            col_indexes=False)
79 76
        
80 77
        # Remove rows from any failed COPY FROM
......
112 109
            finally:
113 110
                line_in.close() # also closes proc.stdout
114 111
                proc.wait()
112
            
113
            if has_row_num: sql.add_row_num(db, table)
115 114
        sql.with_savepoint(db, load_)
116 115
    
117 116
    if input_cmd != []:

Also available in: Unified diff