Ejemplo n.º 1
0
    def restore_database(self, input_path):
        """
        Feed a mysqldump dumpfile to the mysql binary on stdin.
        :param input_path:
        :return:
        """
        input_obj = resolve_input(input_path)
        dumpsize = input_obj.get_size()

        try:
            batch_processor = self.__runner.open_batch_processor()
            with input_obj.open() as dumpfile_data:
                with tqdm(
                        desc="Restoring",
                        total=dumpsize,
                        unit="B",
                        unit_scale=True,
                        unit_divisor=1000,
                ) as bar:
                    for chunk in self.__read_until_empty_byte(dumpfile_data):
                        batch_processor.write(chunk)
                        batch_processor.flush()
                        bar.update(len(chunk))
        finally:
            self.__runner.close_batch_processor()
Ejemplo n.º 2
0
 def test_resolve_unknown(self):
     with pytest.raises(UnknownInputTypeError):
         resolve_input("unknown_file.bbs")
Ejemplo n.º 3
0
 def test_resolve_gzip(self):
     for path in self.test_path_examples:
         test_path = path + "test.sql.gz"
         with self.subTest(i=test_path):
             assert isinstance(resolve_input(test_path), GzipInput)
Ejemplo n.º 4
0
 def test_resolve_raw(self):
     for path in self.test_path_examples:
         test_path = path + "test.sql"
         with self.subTest(i=test_path):
             assert isinstance(resolve_input(test_path), RawInput)
Ejemplo n.º 5
0
def test_resolve_stdin():
    assert isinstance(resolve_input("-"), StdInInput)