Skip to content

SchemaDefinition

SchemaDefinition

Bases: BaseDefinition

Create and manage a metadata schema.

Strategy

Guidance on how to use this definition is in the strategies section on Schema Strategies.

Parameters:

Name Type Description Default
source Path | str | SchemaModel | None

A path to a json file containing a saved schema, or a dictionary conforming to the SchemaModel.

None
Example

Create a new SchemaDefinition as follows:

import whyqd as qd

schema: qd.models.SchemaModel = {
    "name": "urban_population",
    "title": "Urban population",
    "description": "Urban population refers to people living in urban areas as defined by national statistical offices.",
}
schema_destination = qd.SchemaDefinition()
schema_destination.set(schema=schema)

fields: CRUDField property

Returns the active crud model for all Field operations. See Field CRUD for API.

Returns:

Type Description
CRUDField

For all Field CRUD behaviours.

get: SchemaModel | None property

Get the schema model.

Returns:

Type Description
SchemaModel | None

Pydantic SchemaModel or None

derive_model(*, data)

Derive a schema model from a data source model.

Parameters:

Name Type Description Default
data DataSourceModel | dict

A model defining a single data source

required

set(*, schema=None)

Update or create the schema.

Parameters:

Name Type Description Default
schema Path | str | SchemaModel | None

A dictionary, or path to a dictionary or json file, conforming to the SchemaModel.

None