> ## Documentation Index
> Fetch the complete documentation index at: https://developer.synopsys.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Database

### *class* Database

Represents an MI database, and provides access to its tables, unit systems, and record link groups.

### Notes

Do not create instances of this class; it represents a pre-existing database structure. Use [`Session.get_db()`](https://developer.synopsys.com/docs/granta-mi/granta-mi-scripting-toolkit/streamlined_api/session#ansys.grantami.core.mi.Session.get_db)
to access an instance of this class.

#### dimensionally\_equivalent\_units(unit)

Returns all units which are dimensionally equivalent to the specified unit, with conversion factor and offset.

* **Parameters:**
  **unit** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) – The unit to find equivalent units for.
* **Returns:**
  Dictionary mapping unit symbols to their conversion factors and offsets.
* **Return type:**
  [dict](https://docs.python.org/3/library/stdtypes.html#dict)\[[str](https://docs.python.org/3/library/stdtypes.html#str), [dict](https://docs.python.org/3/library/stdtypes.html#dict)\[[str](https://docs.python.org/3/library/stdtypes.html#str), [float](https://docs.python.org/3/library/functions.html#float)]]

### Notes

Makes a single call to the Service Layer and caches the results.

### Examples

```python theme={null}
>>> db.dimensionally_equivalent_units(unit='kg')  
{'g': {'factor': 1000.0, 'offset': 0.0}}
```

#### get\_record\_by\_id(hguid=None, vguid=None, history\_identity=None, version\_number=None)

Returns the [`Record`](https://developer.synopsys.com/docs/granta-mi/granta-mi-scripting-toolkit/streamlined_api/record#ansys.grantami.core.mi_record_classes.Record) object with the following (sets of) references in priority order.

1. `vguid` (record version GUID): Uniquely identifies specific version of record.
2. `history_identity` (record history identity): Uniquely identifies record only, and optionally
   `version_number` (record version number).
3. `hguid` (record history GUID): Uniquely identifies record only.

If `vguid` or `version_number` are not provided for version controlled records, this method will
return the latest available version of the record available to the user. The latest available version
is dependent on the user’s Granta MI permissions.

* **Parameters:**
  * **hguid** ([*str*](https://docs.python.org/3/library/stdtypes.html#str) *,* *optional*) – Record history GUID: uniquely identifies record.
  * **vguid** ([*str*](https://docs.python.org/3/library/stdtypes.html#str) *,* *optional*) – Record version GUID: uniquely identifies record version.
  * **history\_identity** ([*int*](https://docs.python.org/3/library/functions.html#int) *,* *optional*) – Record history identity.
  * **version\_number** ([*int*](https://docs.python.org/3/library/functions.html#int) *,* *optional*) – Record version number.
* **Returns:**
  Record object with the specified ID.
* **Return type:**
  [`Record`](https://developer.synopsys.com/docs/granta-mi/granta-mi-scripting-toolkit/streamlined_api/record#ansys.grantami.core.mi_record_classes.Record)

### Notes

Makes a Service Layer call.

#### get\_records\_by\_ids(record\_identifiers)

Returns a [`Record`](https://developer.synopsys.com/docs/granta-mi/granta-mi-scripting-toolkit/streamlined_api/record#ansys.grantami.core.mi_record_classes.Record) object for each identifier provided.

Each element in the `record_identifiers` parameter should be a dictionary with one or more of the
following (sets of) references in priority order:

1. `vguid` (record version GUID): Uniquely identifies specific version of record.
2. `history_identity` (record history identity): Uniquely identifies record only, and optionally
   `version_number` (record version number).
3. `hguid` (record history GUID): Uniquely identifies record only.

If `vguid` or `version_number` are not provided for version controlled records, this method will
return the latest available version of the record available to the user. The latest available version
is dependent on the user’s Granta MI permissions.

The returned list of records will have the same number of elements as the provided list of identifiers.
If no record corresponds to that identifier then the corresponding item in the returned list will be [`None`](https://docs.python.org/3/library/constants.html#None).

* **Parameters:**
  **record\_identifiers** (*Sequence* *\[*[*dict*](https://docs.python.org/3/library/stdtypes.html#dict) *\[*[*str*](https://docs.python.org/3/library/stdtypes.html#str) *,* [*str*](https://docs.python.org/3/library/stdtypes.html#str) *|* [*int*](https://docs.python.org/3/library/functions.html#int) *]* *]*) – Sequence of dictionaries containing record identifiers.
* **Return type:**
  list\[[`Record`](https://developer.synopsys.com/docs/granta-mi/granta-mi-scripting-toolkit/streamlined_api/record#ansys.grantami.core.mi_record_classes.Record) | [`None`](https://docs.python.org/3/library/constants.html#None)]

### Notes

Makes multiple Service Layer calls depending on number of identifiers provided.

#### get\_table(name)

Returns the [`Table`](https://developer.synopsys.com/docs/granta-mi/granta-mi-scripting-toolkit/streamlined_api/table#ansys.grantami.core.mi_tree_classes.Table) object with the specified name.

Case-insensitive.

* **Parameters:**
  **name** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) – Name of the table.
* **Return type:**
  [`Table`](https://developer.synopsys.com/docs/granta-mi/granta-mi-scripting-toolkit/streamlined_api/table#ansys.grantami.core.mi_tree_classes.Table)
* **Raises:**
  [**KeyError**](https://docs.python.org/3/library/exceptions.html#KeyError) – If no table with the specified name exists in the database.

#### get\_table\_by\_guid(guid)

Returns the [`Table`](https://developer.synopsys.com/docs/granta-mi/granta-mi-scripting-toolkit/streamlined_api/table#ansys.grantami.core.mi_tree_classes.Table) object with the specified GUID.

Case-insensitive.

* **Parameters:**
  **guid** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) – GUID of the table.
* **Return type:**
  [`Table`](https://developer.synopsys.com/docs/granta-mi/granta-mi-scripting-toolkit/streamlined_api/table#ansys.grantami.core.mi_tree_classes.Table)
* **Raises:**
  [**KeyError**](https://docs.python.org/3/library/exceptions.html#KeyError) – If no table with the specified GUID exists in the database.

#### refetch\_unit\_systems()

Fetches the unit systems associated with the database.

### Notes

Makes a Service Layer call.

#### refresh\_tables()

Performs a Foundation API [`BrowseService.get_tables()`](https://developer.synopsys.com/docs/granta-mi/granta-mi-scripting-toolkit/foundation_api#ansys.grantami.backend.soap.BrowseService.BrowseService.get_tables) request and creates a new list of tables.

Also updates the attributes in each table.

### Notes

Makes a Service Layer call.

#### search\_for\_records\_by\_name(name)

Performs a search on record name across the database.

Returns only the [`Record`](https://developer.synopsys.com/docs/granta-mi/granta-mi-scripting-toolkit/streamlined_api/record#ansys.grantami.core.mi_record_classes.Record) objects whose short or long names are an exact match for `name`.
Case-insensitive. This method searches in the currently active subsets for each table, and will raise
an exception if a table has more than one active subset.

* **Parameters:**
  **name** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) – Name to search for.
* **Return type:**
  list\[[`Record`](https://developer.synopsys.com/docs/granta-mi/granta-mi-scripting-toolkit/streamlined_api/record#ansys.grantami.core.mi_record_classes.Record)]

### Notes

Makes a Service Layer call for each table in the database.

#### SEE ALSO

[`Table.search_for_records_by_name()`](https://developer.synopsys.com/docs/granta-mi/granta-mi-scripting-toolkit/streamlined_api/table#ansys.grantami.core.mi_tree_classes.Table.search_for_records_by_name)
: Searches within a single table.

#### search\_for\_records\_by\_text(text)

Performs a simple text search across the database for the string provided.

Returns a list of matching [`Record`](https://developer.synopsys.com/docs/granta-mi/granta-mi-scripting-toolkit/streamlined_api/record#ansys.grantami.core.mi_record_classes.Record) objects. This method does not apply any subset filtering.

* **Parameters:**
  **text** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) – Text to search for.
* **Return type:**
  list\[[`Record`](https://developer.synopsys.com/docs/granta-mi/granta-mi-scripting-toolkit/streamlined_api/record#ansys.grantami.core.mi_record_classes.Record)]

### Notes

Makes a Service Layer call for each table in the database.

#### SEE ALSO

[`Table.search_for_records_by_text()`](https://developer.synopsys.com/docs/granta-mi/granta-mi-scripting-toolkit/streamlined_api/table#ansys.grantami.core.mi_tree_classes.Table.search_for_records_by_text)
: Searches within a single table.

#### search\_for\_records\_where(list\_of\_criteria, silent=True)

Performs a search using criteria within tables across the database.

Use [`Table.search_for_records_where()`](https://developer.synopsys.com/docs/granta-mi/granta-mi-scripting-toolkit/streamlined_api/table#ansys.grantami.core.mi_tree_classes.Table.search_for_records_where) to narrow your search to a single table.

Criteria searches can be performed at the database level only if the provided `list_of_criteria` is not
table specific, i.e. all criterion apply to pseudo-attributes.

If any criterion is specific to an attribute, then the criterion is table specific and the search will be
performed on the table.

* **Parameters:**
  * **list\_of\_criteria** (list\[[`SearchCriterion`](https://developer.synopsys.com/docs/granta-mi/granta-mi-scripting-toolkit/streamlined_api/supporting#ansys.grantami.core.mi_meta_classes.SearchCriterion)]) – List of search criteria.
  * **silent** ([*bool*](https://docs.python.org/3/library/functions.html#bool) *,* *default: True*) – Whether to ignore errors caused by non-existent attributes.
* **Returns:**
  A list of Record objects that match the provided criteria.
* **Return type:**
  list\[[`Record`](https://developer.synopsys.com/docs/granta-mi/granta-mi-scripting-toolkit/streamlined_api/record#ansys.grantami.core.mi_record_classes.Record)]
* **Raises:**
  * [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If the `list_of_criteria` comprise criteria in multiple tables.
  * [**KeyError**](https://docs.python.org/3/library/exceptions.html#KeyError) – If the search criteria include an attribute that does not exist in the database and `silent` is
    [`False`](https://docs.python.org/3/library/constants.html#False).

### Notes

Makes a Service Layer call for each table in the database.

Tabular column criteria are aggregated by column name when processed server-side, effectively restricting
results to records where a single row must meet all criteria on the same column.

To perform a search with multiple tabular column criteria defined on the same column, and obtain results
where the criteria can be met by individual different rows, perform individual searches for each criterion
and compute the intersection of the resulting lists of records.

#### *property* absolute\_temperatures *: [bool](https://docs.python.org/3/library/functions.html#bool)*

Whether the [`Database`](#ansys.grantami.core.mi_tree_classes.Database) uses absolute temperature units (Kelvin/Rankine) or not (Celsius/Fahrenheit).

Default value is [`False`](https://docs.python.org/3/library/constants.html#False).

* **Return type:**
  [bool](https://docs.python.org/3/library/functions.html#bool)

#### *property* currency *: [str](https://docs.python.org/3/library/stdtypes.html#str)*

Database currency code.

* **Return type:**
  [str](https://docs.python.org/3/library/stdtypes.html#str)

#### *property* db\_key *: [str](https://docs.python.org/3/library/stdtypes.html#str)*

Database key.

* **Return type:**
  [str](https://docs.python.org/3/library/stdtypes.html#str)

#### *property* guid *: [str](https://docs.python.org/3/library/stdtypes.html#str)*

GUID of the database.

* **Return type:**
  [str](https://docs.python.org/3/library/stdtypes.html#str)

#### *property* mi *: [Session](https://developer.synopsys.com/docs/granta-mi/granta-mi-scripting-toolkit/streamlined_api/session.md#ansys.grantami.core.mi.Session)*

Granta MI Session used to create or access the [`Database`](#ansys.grantami.core.mi_tree_classes.Database) object.

Used for any Service Layer calls made by the [`Database`](#ansys.grantami.core.mi_tree_classes.Database).

* **Returns:**
  The session object.
* **Return type:**
  [`Session`](https://developer.synopsys.com/docs/granta-mi/granta-mi-scripting-toolkit/streamlined_api/session#ansys.grantami.core.mi.Session)

#### *property* name *: [str](https://docs.python.org/3/library/stdtypes.html#str)*

Name of the database.

* **Return type:**
  [str](https://docs.python.org/3/library/stdtypes.html#str)

#### *property* parameters *: [Dict](https://docs.python.org/3/library/typing.html#typing.Dict)\[[str](https://docs.python.org/3/library/stdtypes.html#str), [DatabaseParameter](https://developer.synopsys.com/docs/granta-mi/granta-mi-scripting-toolkit/streamlined_api/supporting.md#ansys.grantami.core.mi_attribute_classes.DatabaseParameter)]*

Parameters associated with the database, indexed by name.

* **Return type:**
  dict\[str, [`DatabaseParameter`](https://developer.synopsys.com/docs/granta-mi/granta-mi-scripting-toolkit/streamlined_api/supporting#ansys.grantami.core.mi_attribute_classes.DatabaseParameter)]

#### *property* record\_link\_groups *: [List](https://docs.python.org/3/library/typing.html#typing.List)\[[LinkGroupDetails](https://developer.synopsys.com/docs/granta-mi/granta-mi-scripting-toolkit/streamlined_api/supporting.md#ansys.grantami.core.mi_meta_classes.LinkGroupDetails)]*

All record link groups in the database.

* **Return type:**
  list\[[`LinkGroupDetails`](https://developer.synopsys.com/docs/granta-mi/granta-mi-scripting-toolkit/streamlined_api/supporting#ansys.grantami.core.mi_meta_classes.LinkGroupDetails)]

#### *property* tables *: [List](https://docs.python.org/3/library/typing.html#typing.List)\[[Table](https://developer.synopsys.com/docs/granta-mi/granta-mi-scripting-toolkit/streamlined_api/table.md#ansys.grantami.core.mi_tree_classes.Table)]*

Tables associated with the database.

* **Return type:**
  list\[[`Table`](https://developer.synopsys.com/docs/granta-mi/granta-mi-scripting-toolkit/streamlined_api/table#ansys.grantami.core.mi_tree_classes.Table)]

#### *property* tables\_by\_guid *: [Dict](https://docs.python.org/3/library/typing.html#typing.Dict)\[[str](https://docs.python.org/3/library/stdtypes.html#str), [Table](https://developer.synopsys.com/docs/granta-mi/granta-mi-scripting-toolkit/streamlined_api/table.md#ansys.grantami.core.mi_tree_classes.Table)]*

Tables in the database, as dictionary keyed by GUID.

* **Return type:**
  dict\[str, [`Table`](https://developer.synopsys.com/docs/granta-mi/granta-mi-scripting-toolkit/streamlined_api/table#ansys.grantami.core.mi_tree_classes.Table)]

#### *property* tables\_by\_name *: [Dict](https://docs.python.org/3/library/typing.html#typing.Dict)\[[str](https://docs.python.org/3/library/stdtypes.html#str), [Table](https://developer.synopsys.com/docs/granta-mi/granta-mi-scripting-toolkit/streamlined_api/table.md#ansys.grantami.core.mi_tree_classes.Table)]*

Tables in the database, as dictionary keyed by name.

* **Return type:**
  dict\[str, [`Table`](https://developer.synopsys.com/docs/granta-mi/granta-mi-scripting-toolkit/streamlined_api/table#ansys.grantami.core.mi_tree_classes.Table)]

#### *property* unit\_system *: [str](https://docs.python.org/3/library/stdtypes.html#str)*

Currently selected unit system (default is [`DATABASE_UNIT_SYSTEM`](https://developer.synopsys.com/docs/granta-mi/granta-mi-scripting-toolkit/streamlined_api/constants#ansys.grantami.core.mi_constants.DATABASE_UNIT_SYSTEM)).

* **Return type:**
  [str](https://docs.python.org/3/library/stdtypes.html#str)

#### *property* unit\_systems\_available *: [List](https://docs.python.org/3/library/typing.html#typing.List)\[[str](https://docs.python.org/3/library/stdtypes.html#str)]*

Names of unit systems associated with the database.

* **Return type:**
  [list](https://docs.python.org/3/library/stdtypes.html#list)\[[str](https://docs.python.org/3/library/stdtypes.html#str)]

#### *property* version\_guid *: [str](https://docs.python.org/3/library/stdtypes.html#str)*

Version GUID of the database.

* **Return type:**
  [str](https://docs.python.org/3/library/stdtypes.html#str)
