MambuPy.orm.schema_dummies

Make Dummy ORM objects.

Sample dummies are created here. Please DO NOT TRY to persist them to the DB.

Functions

make_dummy(instance[, relations, ...])

Make an instance to look like an empty dummy.

MambuPy.orm.schema_dummies.make_dummy(instance, relations={}, datetime_default=datetime.datetime(1901, 1, 1, 0, 0), varchar_default='', integer_default=0, numeric_default=0.0, *args, **kwargs)[source]

Make an instance to look like an empty dummy.

Every field of the table is set with zeroes/empty strings. Date fields are set to 01/01/1901.

  • relations is a dictionary to set properties for relationships on the instance.

The keys of the relations dictionary are the name of the fields to be set at the instance.

The values of the relations dictionary must be 2 dimension tuples:

  • first element will be the element to be related.

  • second element will be the name of the backref set on the previous first element of the tuple, as a list containing the instance.

If you wish that no backref to be set you may use any invalid value for a property name, anything other than a string, for example a number. Preferably, use None.

  • datetime_default is the datetime object to use for init datetime fields. Defaults to 01-01-1901

  • varchar_default is the string object to use for init varchar fields. Defaults to “”

  • integer_default is the int object to use for init integer fields. Defaults to 0

  • numeric_default is the float object to use for init numeric fields. Defaults to 0.0

  • kwargs may have the name of a certain field you wish to initialize with a value other than the given by the init_data dicionary. If you give an unexistent name on the columns of the table, they are safely ignored.

Todo

further field types may be set at the init_data dictionary.