from heybooster.helpers.database.mongodb import MongoDBHelper

NAME = "database_name"
URI = "database_uri"

"""
Usage 'with'
"""
with MongoDBHelper(uri=URI, database=NAME) as db:
    result = db.find_one('test_collection', query={'email': '<EMAIL>'})
    result = db.find('test_collection', query={'email': '<EMAIL>'})
    db.insert('test_collection', query={'email': '<EMAIL>'})
    db.insert('test_collection', query={'email': '<EMAIL>'})
    db.find_and_modify('test_collection', query={'email': '<EMAIL>'}, update={"$set": '<EMAIL>'})

"""
Usage for connection manual closing 
"""
db = MongoDBHelper(uri=URI, database=NAME)
result = db.find_one('test_collection', query={'email': '<EMAIL>'})

db.close()
print(result)

from heybooster.helpers.database.mongodb import MongoDBHelper

NAME = "database_name"
URI = "database_uri"

"""
Usage 'with'
"""
with MongoDBHelper(uri=URI, database=NAME) as db:
    result = db.find_one('test_collection', query={'email': '<EMAIL>'})
    result = db.find('test_collection', query={'email': '<EMAIL>'})
    db.insert('test_collection', query={'email': '<EMAIL>'})
    db.insert('test_collection', query={'email': '<EMAIL>'})
    db.find_and_modify('test_collection', query={'email': '<EMAIL>'}, update={"$set": '<EMAIL>'})

"""
Usage for connection manual closing 
"""
db = MongoDBHelper(uri=URI, database=NAME)
result = db.find_one('test_collection', query={'email': '<EMAIL>'})

db.close()
print(result)

Usage 'with' Usage for connection manual closing