MCPcopy Create free account
hub / github.com/edmar/whenx / delete_all_data

Function delete_all_data

scripts/delete_all_data.py:7–23  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5
6
7def delete_all_data():
8 meta = MetaData()
9 meta.reflect(bind=db.get_bind()) # Get the engine associated with the session
10
11 # First, delete child table data
12 child_tables = [table for table in meta.sorted_tables if table.foreign_keys]
13
14 for table in child_tables:
15 db.execute(table.delete())
16
17 # Then, delete parent table data
18 parent_tables = [table for table in meta.sorted_tables if not table.foreign_keys]
19
20 for table in parent_tables:
21 db.execute(table.delete())
22
23 db.commit()
24
25
26if __name__ == "__main__":

Callers 1

delete_all_data.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected