code: def _connect(self):
          
  
          try:
              db = pymysql.connect(user=self.user, passwd=self.passwd,
                                   host=self.host, port=self.port,
                                   db=self.shdb, use_unicode=True)
              return db, db.cursor()
          except Exception:
              logger.error("Database connection error")
              raise
docs: Connect to the MySQL database.