Meta class reference¶
This document covers features of the Meta class. The meta class defines model specific settings and is used as an inner class in the model:
from data_migrator import models
class SampleModel(models.Model):
a = models.IntField(pos=1)
class Meta:
drop_if_none = True
Every model can have its own meta class to define model specific options.
Note
Technically, Meta is just a container and forwarded to Options
-
class
data_migrator.models.options.
Options
(cls, meta, fields)[source]¶ -
__init__
(cls, meta, fields)[source]¶ Options is the Model Meta data container
The Options class is the true meta data container and parser for a
Model
. It contains all flag and fields references for model handling. Use these flags in the Meta sub class of aModel
.Parameters: - cls – the Model this Options object is refering too
- meta – the reference to a Meta class
- fields (list) – list of all field definitions
-
drop_if_none
¶ names of the columns to check for None, Is a list of field names as defined. If set data-migrator will check if fields are not None and drop if one of the columns is.
Type: list
-
drop_non_unique
¶ If
True
, data-migrator will drop values if the column uniqueness check fails (after parsing). Default isFalse
.Any field can be defined as a unique column. Any field set so, is checked after scanning and just before save-ing.
Type: boolean
-
emitter
¶ If set, data-migrator will use this emitter instead of the default emitter.
Type: BaseEmitter
-
fail_non_unique
¶ If
True
, data-migrator will fail as a whole if the column uniqueness check fails (after parsing). Default isFalse
.Any field can be defined as a unique column. Any field set so, is checked after scanning and just before save-ing.
Type: boolean
-
fail_non_validated
¶ If
True
, data-migrator will fail as a whole if the column validation check fails (after parsing). Default isFalse
.Any field can have its own validator, this is a rough method to prevent bad data from being transformed and loaded.
Type: boolean
-
fail_on_data_exception
¶ If
True
, data-migrator will fail as a whole if row parsing contains data issues. Default isTrue
.Type: boolean
-
file_name
¶ If set, data-migrator will use this as file_name for the emitter instead of the default filename based on model_name.
Type: string
-
table_name
¶ If set, data-migrator will use this as table_name for the emitter instead of the default table_name based on model_name.
Type: string
-
prefix
¶ If set, data-migrator will use this list of statements as a preamble in the generation of the output statements.
By default an emitter uses this to clear the old state.
Type: string
-
remark
¶ If set, data-migrator will use this as the remark attribute in the Model, default=’remark’. Use this for example if you have a
remark
field in your model and need to free the keyword.Type: string
-
strict
¶ If
True
, data-migrator will be strict on the model and does not allow values outside of the definitions. Default isNone
.Type: boolean
-
manager
¶ If set, data-migrator will use this as the manager for this model.
This is useful if the
transform
method needs to be overridden.Type: BaseManager
Raises: DefinitionException
– raised if any of the defintions is not to spec.
-
Note
Note that only NullXXXFields actually can be None
after scanning and
parsing. Non Null fields are set to their default value.