KarrLab/datanator_query_python

View on GitHub
datanator_query_python/util/motor_util.py

Summary

Maintainability
A
1 hr
Test Coverage
A
100%
import motor.motor_asyncio


class MotorUtil:

    def __init__(self, MongoDB=None, replicaSet=None, db='test',
                 verbose=False, max_entries=float('inf'), username=None, 
                 password=None, authSource='admin', readPreference='nearest'):
        string = "mongodb+srv://{}:{}@{}/{}?authSource={}&retryWrites=true&w=majority&readPreference={}".format(username, password, MongoDB, db, authSource, readPreference)
        self.client = motor.motor_asyncio.AsyncIOMotorClient(string)