Skip to content

Attribute Operations

Functions for setting and retrieving component attributes.

set_static_attribute

python
set_static_attribute((conn: sqlite3.Connection, component_id: int, attribute_name: str, value: pyconvexity.core.types.StaticValue, scenario_id: Optional[int] = None) -> None)

Set a static attribute value for a component in a specific scenario.

Parameters:

  • conn: Database connection
  • component_id: Component ID
  • attribute_name: Name of the attribute
  • value: Static value to set
  • scenario_id: Scenario ID (uses master scenario if None)

Raises:

  • ComponentNotFound: If component doesn't exist
  • ValidationError: If attribute doesn't allow static values or validation fails

set_timeseries_attribute

python
set_timeseries_attribute((conn: sqlite3.Connection, component_id: int, attribute_name: str, timeseries: Union[pyconvexity.core.types.Timeseries, List[float]], scenario_id: Optional[int] = None) -> None)

Set a timeseries attribute value for a component in a specific scenario.

Parameters:

  • conn: Database connection
  • component_id: Component ID
  • attribute_name: Name of the attribute
  • timeseries: Timeseries object or list of float values
  • scenario_id: Scenario ID (uses master scenario if None)

Raises:

  • ComponentNotFound: If component doesn't exist
  • ValidationError: If attribute doesn't allow timeseries values
  • TimeseriesError: If timeseries serialization fails

get_attribute

python
get_attribute((conn: sqlite3.Connection, component_id: int, attribute_name: str, scenario_id: Optional[int] = None) -> pyconvexity.core.types.AttributeValue)

Get an attribute value with scenario fallback logic.

Parameters:

  • conn: Database connection
  • component_id: Component ID
  • attribute_name: Name of the attribute
  • scenario_id: Scenario ID (uses master scenario if None)

Returns:

AttributeValue containing either static or timeseries data

Raises:

  • ComponentNotFound: If component doesn't exist
  • AttributeNotFound: If attribute doesn't exist

delete_attribute

python
delete_attribute((conn: sqlite3.Connection, component_id: int, attribute_name: str, scenario_id: Optional[int] = None) -> None)

Delete an attribute from a specific scenario.

Parameters:

  • conn: Database connection
  • component_id: Component ID
  • attribute_name: Name of the attribute
  • scenario_id: Scenario ID (uses master scenario if None)

Raises:

  • AttributeNotFound: If attribute doesn't exist

list_component_attributes

python
list_component_attributes((conn: sqlite3.Connection, component_id: int) -> List[str])

List all attribute names for a component.

Parameters:

  • conn: Database connection
  • component_id: Component ID

Returns:

List of attribute names

© Copyright 2025 Bayesian Energy