aswi2020sebela-gitlab/modules/crawler/ResetDatabaseData.py @ 92764b8b
1 | 1187e871 | petrh | from Utilities.Database import DatabaseLoader |
---|---|---|---|
2 | |||
3 | |||
4 | def clean_database(): |
||
5 | """
|
||
6 | Deletes all collections from database
|
||
7 | """
|
||
8 | # Create connection
|
||
9 | mydb = DatabaseLoader.create_database_connection() |
||
10 | |||
11 | # Retrieve list of all collections
|
||
12 | collections = mydb.list_collection_names() |
||
13 | |||
14 | # Drop of all collections
|
||
15 | for name in collections: |
||
16 | mydb[name].drop() |
||
17 | |||
18 | print("Database Cleaned") |
||
19 | |||
20 | |||
21 | 728f8c5d | petrh | clean_database() |