Поиск по тегам
This commit is contained in:
21
1.py
Normal file
21
1.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from pymongo import MongoClient
|
||||
|
||||
|
||||
def clean_tags_in_database():
|
||||
client = MongoClient('mongodb://localhost:27017/')
|
||||
db = client['Manga']
|
||||
collection = db['Hentai_Manga']
|
||||
|
||||
for manga in collection.find():
|
||||
if 'tags' in manga:
|
||||
cleaned_tags = [tag.strip() for tag in manga['tags'] if tag.strip()]
|
||||
if cleaned_tags != manga['tags']:
|
||||
collection.update_one(
|
||||
{'_id': manga['_id']},
|
||||
{'$set': {'tags': cleaned_tags}}
|
||||
)
|
||||
print("Теги успешно очищены от пробелов")
|
||||
|
||||
|
||||
# Вызовите эту функцию один раз
|
||||
clean_tags_in_database()
|
||||
Reference in New Issue
Block a user