1
|
from Utilities.Database import DatabaseLoader
|
2
|
|
3
|
|
4
|
def remove_dataset_database(dataset_name):
|
5
|
"""
|
6
|
Removes dataset entries from database
|
7
|
Args:
|
8
|
dataset_name: name of dataset that has existing configuration file
|
9
|
"""
|
10
|
# Creating connection
|
11
|
mydb = DatabaseLoader.create_database_connection()
|
12
|
|
13
|
# collection where are specified aviable datasets
|
14
|
collection_datasets = mydb[DatabaseLoader.MONGODB_DATASET_COLLECTION]
|
15
|
|
16
|
collection_datasets.delete_one({"name": dataset_name})
|
17
|
print("Removing record from DATASETS collection")
|
18
|
|
19
|
|
20
|
# Retrieve list of all collections
|
21
|
collections = mydb.list_collection_names()
|
22
|
|
23
|
# Drop of all collections
|
24
|
for name in collections:
|
25
|
if name.startswith(dataset_name):
|
26
|
mydb[name].drop()
|
27
|
print("Dropping: " + name)
|
28
|
|
29
|
print("Database Cleaned")
|
30
|
|
31
|
print("Zadejte jméno Datasetu který chcete odstranit z databáze:\n")
|
32
|
remove_dataset_database(input())
|