class_docstr: This handler handles connection and execution of the MongoDB statements.
class_docstr_tok: ["This","handler","handles","connection","and","execution","of","the","MongoDB","statements","."]
docstr: Check the connection of the database
  :return: success status and error message if error occurs
docstr_tok: ["Check","the","connection","of","the","database",":","return",":","success","status","and","error","message","if","error","occurs"]
code: def check_connection(self) -> StatusResponse:
      """
      Check the connection of the database
      :return: success status and error message if error occurs
      """
  
      result = StatusResponse(False)
      need_to_close = self.is_connected is False
  
      try:
          con = self.connect()
          con.server_info()
          result.success = True
      except Exception as e:
          logger.error(
              f"Error connecting to MongoDB {self.database}, {e}!"
          )
          result.error_message = str(e)
  
      if result.success is True and need_to_close:
          self.disconnect()
      if result.success is False and self.is_connected is True:
          self.is_connected = False
  
      return result
  
imports: import re
  import time
  from collections import OrderedDict
  from bson import ObjectId
  import certifi
  import pandas
  import pymongo
  from pymongo import MongoClient
  from mindsdb_sql.parser.ast.base import ASTNode
  from mindsdb.utilities import log
  from mindsdb.integrations.libs.base import DatabaseHandler
  from mindsdb.integrations.libs.const import HANDLER_CONNECTION_ARG_TYPE
  from mindsdb.integrations.libs.response import HandlerStatusResponse, HandlerResponse, RESPONSE_TYPE
  from .utils.mongodb_render import MongodbRender
  from mindsdb.api.mongo.utilities.mongodb_query import MongoQuery
  from mindsdb.api.mongo.utilities.mongodb_parser import MongodbParser
label_desc: Use image node_id 6 for calling the MongoDBHandler obj's underlying member method code with example usage: obj.check_connection() and returns: result