Project

General

Profile

« Previous | Next » 

Revision 3149

csv2db: Fixed bug where CREATE TABLE statement was cached, causing it not to be re-executed after a rollback due to a failed COPY FROM. Avoid re-creating the table after a failed COPY FROM, and instead just remove any existing rows.

View differences:

bin/csv2db
84 84
        typed_cols = [sql_gen.TypedCol('row_num', 'serial', nullable=False)]+[
85 85
            sql_gen.TypedCol(v, 'text') for v in col_names]
86 86
        
87
        log('Creating table')
88
        sql.create_table(db, table, typed_cols, col_indexes=False)
89
        
90
        # Remove rows from any failed COPY FROM
91
        sql.truncate(db, table)
92
        
87 93
        def load_():
88
            log('Creating table')
89
            sql.create_table(db, table, typed_cols, col_indexes=False)
90
            
91 94
            # Create COPY FROM statement
92 95
            if use_copy_from[0]:
93 96
                cur = db.db.cursor()

Also available in: Unified diff