schema¶
-
class
pemi.schema.
Schema
(*args, **kwargs)[source]¶ A schema is a thing.
-
metapply
(elem, func)[source]¶ Allows one to create/modify metadata elements using a function
- Parameters
elem (str) – Name of the metadata element to create or modify
func (func) – Function that accepts a single
pemi.Field
argument and returns the value of the metadata element indicated byelem
- Returns
A new
pemi.Schema
with the updated metadata- Return type
pemi.Schema
Example
Suppose we wanted to add some metadata to a schema that will be used to construct a SQL statement:
pemi.schema.Schema( id=StringField(), name=StringField() ).metapply( 'sql', lambda field: 'students.{} AS student_{}'.format(field.name, field.name) )
-