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
toNone
.
-
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
], …]
-