Revision 3081
Added by Aaron Marcuse-Kubitza over 12 years ago
sql_io.py | ||
---|---|---|
7 | 7 |
import strings |
8 | 8 |
import util |
9 | 9 |
|
10 |
##### Data cleanup |
|
11 |
|
|
12 |
def cleanup_table(db, table, cols): |
|
13 |
table = sql_gen.as_Table(table) |
|
14 |
cols = map(sql_gen.as_Col, cols) |
|
15 |
|
|
16 |
expr = ('nullif(nullif(trim(both from %s), '+db.esc_value('')+'), ' |
|
17 |
+db.esc_value(r'\N')+')') |
|
18 |
changes = [(v, sql_gen.CustomCode(expr % v.to_str(db))) |
|
19 |
for v in cols] |
|
20 |
|
|
21 |
sql.update(db, table, changes, in_place=True) |
|
22 |
|
|
10 | 23 |
##### Error tracking |
11 | 24 |
|
12 | 25 |
def track_data_error(db, errors_table, cols, value, error_code, error): |
Also available in: Unified diff
Moved Data cleanup from sql.py to sql_io.py