Add variable and unit#

variable#

metacatalog.api.add_variable(session: Session, name: str, symbol: str, column_names: List[str], unit: Union[int, str], keyword: Union[int, str] = None) Variable#

Add a new variable to the database.

Parameters:
  • session (sqlalchemy.Session) – SQLAlchemy session connected to the database.

  • name (str) – The variable name. Max 64 letters.

  • symbol (str) – The variable symbol. Try to use the correct physical variable symbols and avoid dublicates.

  • column_names (list) –

    New in version 0.3.0.

    List of default column names that will be displayed when exporting the data. The columns are named in the same order as they appear in the list.

  • unit (int, str) – Either the id or full name of the unit to be linked to this variable.

  • keyword (int, str) –

    New in version 0.8.4.

    Either the id or full path of the keyword to be linked to this variable. It is strongly recommended to add a keyword from a controlled thesaurus to a newly created variable to improve the findability of the variable.

Returns:

variable – Variable instance of the added variable entity

Return type:

metacatalog.models.Variable

unit#

metacatalog.api.add_unit(session: Session, name: str, symbol: str, si: str = None) Unit#

Add a new unit to the database

Parameters:
  • session (sqlalchemy.Session) – SQLAlchemy session connected to the database.

  • name (str) – The unit name. Max 64 letters.

  • symbol (str) – The unit symbol. Try to use the correct physical unit symbols. Max 12 letters.

  • si (str) – SI representation of the unit. Can be omitted.

Returns:

unit – Unit instance of the added unit entity

Return type:

metacatalog.Unit