| 88 | |
| 89 | |
| 90 | def clear_table(model): |
| 91 | table_name = model._meta.db_table |
| 92 | model.objects.all().delete() |
| 93 | print("building " + table_name) |
| 94 | # Reset DB auto increments to start at 1 |
| 95 | if DB_VENDOR == "sqlite": |
| 96 | DB_CURSOR.execute( |
| 97 | "DELETE FROM sqlite_sequence WHERE name = " + "'" + table_name + "'" |
| 98 | ) |
| 99 | else: |
| 100 | DB_CURSOR.execute( |
| 101 | "SELECT setval(pg_get_serial_sequence(" |
| 102 | + "'" |
| 103 | + table_name |
| 104 | + "'" |
| 105 | + ",'id'), 1, false);" |
| 106 | ) |
| 107 | |
| 108 | |
| 109 | def build_generic(model_classes, file_name, csv_record_to_objects): |