d1160a66e0
Почистил код. Удалил лишнее.
19 lines
628 B
Python
19 lines
628 B
Python
from pymongo import MongoClient
|
|
|
|
|
|
class UseDB:
|
|
def __init__(self, collection_name):
|
|
self.series_collection = None
|
|
self.client = MongoClient('localhost', 27017)
|
|
self.db = self.client['toads']
|
|
self.series_collection = self.db[collection_name]
|
|
|
|
def find_document(self, elements):
|
|
return [x for x in self.series_collection.find(elements)]
|
|
|
|
def insert_document(self, data):
|
|
return self.series_collection.insert_one(data).inserted_id
|
|
|
|
def update_document(self, query_elements, new_values):
|
|
self.series_collection.update_one(query_elements, {'$set': new_values})
|