metad.metadata module¶
Classes
|
Read, write, and validate metadata. |
Functions
|
-
class
metad.metadata.
MetaData
[source]¶ Bases:
object
Read, write, and validate metadata.
The MetaData object provides methods to help read, write, and validate metadata. It uses the JSON schema, which can be found in schema.json, to validate the structure of the metadata and applies additional logic checks internally.
Methods
add_constraint
(constraint)Add the constraint object to the metadata.
add_field
(table_name, field)add_foreign_key
(foreign_key)Add the foreign key object to the metadata.
add_table
(table)Add the table object to the metadata.
from_json
(path_to_json)Load a MetaData object from a JSON file.
get_foreign_keys
([table_name])get_table
(table_name)set_foreign_keys
(foreign_keys)set_tables
(tables)to_json
([path_to_json])Export the MetaData object to a JSON file.
validate
()Validate the contents of this metadata object.
-
add_constraint
(constraint)[source]¶ Add the constraint object to the metadata.
The constraint table object must conform the the JSON schema specification.
- Parameters
constraint (dict) – A dictionary representing the constraint relationship.
-
add_foreign_key
(foreign_key)[source]¶ Add the foreign key object to the metadata.
The foreign key object must conform the the JSON schema specification.
- Parameters
foreign_key (dict) – A dictionary representing the foreign key relationship.
-
add_table
(table)[source]¶ Add the table object to the metadata.
The table object must conform the the JSON schema specification.
- Parameters
table (dict) – A dictionary representing the table.
-
static
from_json
(path_to_json)[source]¶ Load a MetaData object from a JSON file.
- Parameters
path_to_json (str) – The path to the JSON file.
- Returns
An instance of the MetaData object.
- Return type
-
-
metad.metadata.
validate
(data)¶