docs: def sanitize_from_stream(stream, config):
      """
      Reads dump of MySQL database from given stream and sanitizes it.
  
      :param stream: Stream where the database dump is expected to be available
                     from, such as stdout of `mysqldump` process.
      :type stream: file
  
      :param config: Optional sanitizer configuration to be used for sanitation
                     of the values stored in the database.
      :type config: database_sanitizer.config.Configuration|None
      """
      for line in io.TextIOWrapper(stream, encoding="utf-8"):
          # Eat the trailing new line.
          line = line.rstrip("\n")
  
          # If there is no configuration it means that there are no sanitizers
          # available.
          if not config:
              yield line
              continue
  
          # Does the line contain `INSERT INTO` statement? If not, use the line
          # as-is and continue into next one.
          insert_into_match = INSERT_INTO_PATTERN.match(line)
          if not insert_into_match:
              yield line
              continue
  
          table_name = insert_into_match.group("table")
          column_names = parse_column_names(insert_into_match.group("columns"))
  
          # Collect sanitizers possibly used for this table and place them into
          # a dictionary from which we can look them up by index later.
          sanitizers = {}
          for index, column_name in enumerate(column_names):
              sanitizer = config.get_sanitizer_for(
                  table_name=table_name,
                  column_name=column_name,
              )
              if sanitizer:
                  sanitizers[index] = sanitizer
  
          # If this table has no sanitizers available, use the line as-is and
          # continue into next line.
          if len(sanitizers) == 0:
              yield line
              continue
  
          # Constructs list of tuples containing sanitized column names.
          sanitized_value_tuples = []
          for values in parse_values(insert_into_match.group("values")):
              if len(column_names) != len(values):
                  raise ValueError("Mismatch between column names and values")
              sanitized_values = []
              for index, value in enumerate(values):
                  sanitizer_callback = sanitizers.get(index)
                  if sanitizer_callback:
                      value = sanitizer_callback(value)
                  sanitized_values.append(encode_mysql_literal(value))
              sanitized_value_tuples.append(sanitized_values)
  
          # Finally create new `INSERT INTO` statement from the sanitized values.
          yield "INSERT INTO `%s` (%s) VALUES %s;" % (
              table_name,
              ", ".join("`" + column_name + "`" for column_name in column_names),
              ",".join(
                  "(" + ",".join(value_tuple) + ")"
                  for value_tuple in sanitized_value_tuples
              ),
          )