Revision 2689
Added by Aaron Marcuse-Kubitza over 12 years ago
bin/csv2db | ||
---|---|---|
121 | 121 |
sql.vacuum(db, table) |
122 | 122 |
|
123 | 123 |
log('Creating errors table') |
124 |
errors_table = table+'.errors' |
|
124 | 125 |
typed_cols = [sql_gen.TypedCol('column', 'text NOT NULL'), |
125 | 126 |
sql_gen.TypedCol('value', 'text'), |
126 |
sql_gen.TypedCol('error', 'text')] |
|
127 |
sql.create_table(db, table+'_errors', typed_cols, has_pkey=False) |
|
127 |
sql_gen.TypedCol('error', 'text NOT NULL')] |
|
128 |
sql.create_table(db, errors_table, typed_cols, has_pkey=False) |
|
129 |
ensure_not_null = sql_gen.Function('ensure_not_null', 'functions') |
|
130 |
index_cols = ['column', sql_gen.FunctionCall(ensure_not_null, |
|
131 |
sql_gen.Col('value')), 'error'] |
|
132 |
sql.add_index(db, index_cols, errors_table, unique=True) |
|
128 | 133 |
db.db.commit() |
129 | 134 |
|
130 | 135 |
try: load() |
Also available in: Unified diff
csv2db: Errors table: Add UNIQUE index on all columns