Revision 3081
Added by Aaron Marcuse-Kubitza about 12 years ago
sql.py | ||
---|---|---|
1197 | 1197 |
def empty_db(db, schema='public', **kw_args): |
1198 | 1198 |
'''For kw_args, see tables()''' |
1199 | 1199 |
for table in tables(db, schema, **kw_args): truncate(db, table, schema) |
1200 |
|
|
1201 |
##### Database management |
|
1202 |
|
|
1203 |
##### Data cleanup |
|
1204 |
|
|
1205 |
def cleanup_table(db, table, cols): |
|
1206 |
table = sql_gen.as_Table(table) |
|
1207 |
cols = map(sql_gen.as_Col, cols) |
|
1208 |
|
|
1209 |
expr = ('nullif(nullif(trim(both from %s), '+db.esc_value('')+'), ' |
|
1210 |
+db.esc_value(r'\N')+')') |
|
1211 |
changes = [(v, sql_gen.CustomCode(expr % v.to_str(db))) |
|
1212 |
for v in cols] |
|
1213 |
|
|
1214 |
update(db, table, changes, in_place=True) |
Also available in: Unified diff
Moved Data cleanup from sql.py to sql_io.py