You are looking at the documentation for an older version of the SDV! We are no longer supporting or maintaining this version of the software

Click here to go to the new docs pages.


Metadata.add_table(name, data=None, fields=None, fields_metadata=None, primary_key=None, parent=None, foreign_key=None, constraints=None)[source]

Add a new table to this metadata.

fields list can be a mixture of field names, which will be build automatically from the data, or dictionaries specifying the field details. If a field needs to be analyzed, data has to be also passed.

If parent is given, a relationship will be established between this table and the specified parent.

  • name (str) – Name of the new table.

  • data (str or pandas.DataFrame) – Table to be analyzed or path to the csv file. If it’s a relative path, use root_path to find the file. Only used if fields is not None. Defaults to None.

  • fields (list) – List of field names to build. If None is given, all the fields found in the data will be used. Defaults to None.

  • fields_metadata (dict) – Metadata to be used when creating fields. This will overwrite the metadata built from the fields found in data. Defaults to None.

  • primary_key (str) – Field name to add as primary key, it must not exists. Defaults to None.

  • parent (str) – Table name to refere a foreign key field. Defaults to None.

  • foreign_key (str) – Foreign key field name to parent table primary key. Defaults to None.

  • constraints (list[Constraint, dict]) – List of Constraint objects or dicts representing the constraints for the given table.


ValueError – If the table name already exists or data is not passed and fields need to be built from it.