aswi2020sebela-gitlab/modules/crawler/fully_clean_database.py @ ea92a5e5
1 |
from Utilities.Database import database_loader |
---|---|
2 |
|
3 |
def clean_database(): |
4 |
"""
|
5 |
Drops every collection in database
|
6 |
"""
|
7 |
# Creating connection
|
8 |
mydb = database_loader.create_database_connection() |
9 |
|
10 |
# Retrieve list of all collections
|
11 |
collections = mydb.list_collection_names() |
12 |
|
13 |
# Drop of all collections
|
14 |
for name in collections: |
15 |
print(name) |
16 |
mydb[name].drop() |
17 |
|
18 |
|
19 |
print('Data z databáze budou smazána:') |
20 |
clean_database() |