Emitter class reference¶
Emitters are used to export models to output format.
This module contains all classes for emitters: base and actuals. Currently
the system has two emitters: CSVEmitter
and MySQLEmitter
implemented, of which the last is the default emitter. An emitter provides the
export format for the scanned and cleaned datasets. It also provides preambles
and postambles in the output files, for example to clean the target table
before loading it.
The following classes are defined in this module:
The basic structure for emitting is a combination between
BaseManager
and BaseEmitter
:
e = Emitter(manager=Model.objects)
print e.preamble(header=[..my header lines to add..])
for l in Model.objects.all():
print e.emit(l) # emit is returning a list of strings!
Note
At this moment data-migrator does not an actively take part in schema migrations of any sort. It is purely about cleaning, anonymizing and transforming data (yet!).
MySQLEmitter¶
CSVEmitter¶
JSONEmitter¶
UpdateEmitter¶
-
class
data_migrator.emitters.update.
UpdateEmitter
(*args, **kwargs)[source]¶ MySQL emitter to output MySQL specific update statements
-
base_template
¶ base template to output the object
-
extension
¶ file extension for output file of this emitter. Defaults to .sql
Type: str
Note: at least on field needs to have key=True
-
BaseEmitter¶
-
class
data_migrator.emitters.base.
BaseEmitter
(extension=None, manager=None)[source]¶ Base for emitters of the data-migrator.
-
manager
¶ reference to the manager that is calling this emitter to export objects from that manager
Type: BaseManager
-
extension
¶ file extension for output file of this emitter
Type: str
note:
model_class
andmanager
are linked together-