def connect_to_mongodb(db, host, port=27017, tz_aware=True, user=None, password=None, retry_wait_time=0.1, proxy=True, **kwargs):
 if kwargs.get('replicaSet'):
  mongo_client_class = pymongo.MongoReplicaSetClient
 else:
  mongo_client_class = pymongo.MongoClient
 mongo_conn = pymongo.database.Database(mongo_client_class(host=host, port=port, tz_aware=tz_aware, document_class=dict, **kwargs), db)
 if proxy:
  mongo_conn = MongoProxy(mongo_conn, wait_time=retry_wait_time)
 if ((user is not None) and (password is not None)):
  mongo_conn.authenticate(user, password)
 return mongo_conn

def connect_to_mongodb ( db , host , port = 27017 , tz_aware = True , user = None , password = None , retry_wait_time = 0.1 , proxy = True , ** kwargs ) : if kwargs . get ( 'replicaSet' ) : mongo_client_class = pymongo . MongoReplicaSetClient else : mongo_client_class = pymongo . MongoClient mongo_conn = pymongo . database . Database ( mongo_client_class ( host = host , port = port , tz_aware = tz_aware , document_class = dict , ** kwargs ) , db ) if proxy : mongo_conn = MongoProxy ( mongo_conn , wait_time = retry_wait_time ) if ( ( user is not None ) and ( password is not None ) ) : mongo_conn . authenticate ( user , password ) return mongo_conn
returns a mongodb database connection .