Converters

When creating a new pgdumplib.dump.Dump instance, either directly or by using pgdumplib.load(), you can specify a converter class to use when reading data using the pgdumplib.dump.Dump.read_data() iterator.

The default converter (DataConverter) will only replace columns that have a NULL indicator (\N) with None.

The SmartDataConverter will attempt to convert individual columns to native Python data types.

Creating your own data converter is easy and should simply extend the DataConverter class.

class pgdumplib.converters.DataConverter[source]

Base Row/Column Converter

Base class used for converting row/column data when using the pgdumplib.dump.Dump.read_data() iterator.

This class just splits the row into individual columns and returns the row as tuple of strings, only converting \N to None.

static convert(row)[source]

Convert the string based row into a tuple of columns.

Parameters

row (str) – The row to convert

Return type

tuple

class pgdumplib.converters.NoOpConverter[source]

Performs no conversion on the row passed in

static convert(row)[source]

Returns the row passed in

Parameters

row (str) – The row to convert

Return type

str

class pgdumplib.converters.SmartDataConverter[source]

Attempts to convert columns to native Python data types

Used for converting row/column data with the pgdumplib.dump.Dump.read_data() iterator.

Possible conversion types:

convert(row)[source]

Convert the string based row into a tuple of columns

Return type

Tuple[Union[None, str, int, datetime, Decimal, IPv4Address, IPv4Network, IPv6Address, IPv6Network, UUID], …]