def _MakeConnection(self, database=""):
    first_attempt_time = time.time()
    wait_time = config_lib.CONFIG["Mysql.max_connect_wait"]
    while wait_time == 0 or time.time() - first_attempt_time < wait_time:
      try:
        connection_args = dict(
            user=config_lib.CONFIG["Mysql.database_username"],
            db=database, charset="utf8",
            passwd=config_lib.CONFIG["Mysql.database_password"],
            cursorclass=cursors.DictCursor,
            host=config_lib.CONFIG["Mysql.host"],
            port=config_lib.CONFIG["Mysql.port"])

        dbh = MySQLdb.connect(**connection_args)
        return dbh
      except MySQLdb.OperationalError as e:
        # This is a fatal error, we just raise the top level exception here.
        if "Access denied" in str(e):
          raise Error(str(e))

        if "Can't connect" in str(e):
          logging.warning("Datastore connection retrying after failed with %s.",
                          str(e))
          time.sleep(.5)
          continue
        raise

    raise IOError("Unable to connect to Mysql database.")
Add a record to the response (self.result)
dataset/ETHPy150Open google/grr/grr/lib/data_stores/mysql_advanced_data_store.py/MySQLConnection._MakeConnection--crossover with--dataset/ETHPy150Open polaris-gslb/polaris-gslb/polaris_pdns/core/remotebackend.py/RemoteBackend.add_record