Exemplo n.º 1
0
def load(filepath: str, converter=None):
    """Load a pg_dump file created with -Fd from disk

    :param str filepath: The path to the dump to load
    :param class converter: The data converter class to use
        (Default: :py:class:`pgdumplib.converters.DataConverter`)
    :type converter: pgdumplib.converters.DataConverter or None
    :raises: :py:exc:`ValueError`
    :rtype: pgdumplib.dump.Dump

    """
    from pgdumplib import dump

    return dump.Dump(converter=converter).load(filepath)
Exemplo n.º 2
0
def new(dbname: str = 'pgdumplib', encoding: str = 'UTF8', converter=None):
    """Create a new :py:class:`pgdumplib.dump.Dump` instance

    :param str dbname: The database name for the dump (Default: ``pgdumplib``)
    :param str encoding: The data encoding (Default: ``UTF8``)
    :param converter: The data converter class to use
        (Default: :py:class:`pgdumplib.converters.DataConverter`)
    :type converter: pgdumplib.converters.DataConverter or None
    :rtype: pgdumplib.dump.Dump

    """
    from pgdumplib import dump

    return dump.Dump(dbname, encoding, converter)
Exemplo n.º 3
0
def new(dbname: str = 'pgdumplib',
        encoding: str = 'UTF8',
        converter=None,
        appear_as: str = '12.0'):
    """Create a new :py:class:`pgdumplib.dump.Dump` instance

    :param dbname: The database name for the dump (Default: ``pgdumplib``)
    :param encoding: The data encoding (Default: ``UTF8``)
    :param converter: The data converter class to use
        (Default: :py:class:`pgdumplib.converters.DataConverter`)
    :type converter: pgdumplib.converters.DataConverter or None
    :param appear_as: The version of Postgres to emulate
        (Default: ``12.0``)
    :rtype: pgdumplib.dump.Dump

    """
    from pgdumplib import dump

    return dump.Dump(dbname, encoding, converter, appear_as)
Exemplo n.º 4
0
 def setUpClass(cls) -> None:
     cls.dump_path = pathlib.Path('build') / 'data' / cls.PATH
     cls.dump = dump.Dump(converter=cls.CONVERTER).load(cls.dump_path)
Exemplo n.º 5
0
 def test_postgres_100(self):
     with self.assertRaises(RuntimeError):
         dump.Dump(appear_as='100.0')
Exemplo n.º 6
0
 def test_postgres_12(self):
     instance = dump.Dump(appear_as='12.0')
     self.assertEqual(instance.version, (1, 14, 0))
Exemplo n.º 7
0
 def test_postgres_10_3(self):
     instance = dump.Dump(appear_as='10.3')
     self.assertEqual(instance.version, (1, 13, 0))
Exemplo n.º 8
0
 def test_postgres_9_6_4(self):
     instance = dump.Dump(appear_as='9.6.4')
     self.assertEqual(instance.version, (1, 12, 0))
Exemplo n.º 9
0
 def test_default(self):
     instance = dump.Dump()
     self.assertEqual(instance.version, (1, 14, 0))