def get_db(db, ip='<STR_LIT:localhost>', port=<NUM_LIT>, user=None, password=None):
if platform.system().lower() == '<STR_LIT>':<EOL><INDENT>connect = False<EOL><DEDENT>else:<EOL><INDENT>connect = True<EOL><DEDENT>if user and password:<EOL><INDENT>import urllib<EOL>pwd = urllib.quote_plus(password)<EOL>uri = '<STR_LIT>'.format(user, pwd, ip, port)<EOL>conn = MongoClient(uri, connect=connect)<EOL><DEDENT>else:<EOL><INDENT>conn = MongoClient(ip, port, connect=connect)<EOL><DEDENT>return conn[db]<EOL>
Returns a pymongo Database object.

.. note:

    Both ``user`` and ``password`` are required when connecting to a MongoDB
    database that has authentication enabled.

Arguments:

    db (str): Name of the MongoDB database. Required.

    ip (str): IP address of the MongoDB server. Default is ``localhost``.

    port (int): Port of the MongoDB server. Default is ``27017``.

    user (str): Username, if authentication is enabled on the MongoDB database.
        Default is ``None``, which results in requesting the connection
        without authentication.

    password (str): Password, if authentication is enabled on the MongoDB database.
        Default is ``None``, which results in requesting the connection
        without authentication.