> ## 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.

# Get Started

Load MI Scripting Toolkit, connect to your MI Session, and select a database and table.

## Connect to MI

Import the `granta` libraries and connect to Granta MI via the Service Layer using Windows authentication,
replacing `my.server.name` with the name of your Granta MI server.

```python theme={null}
from GRANTA_MIScriptingToolkit import granta as mpy

mi = mpy.connect("http://my.server.name/mi_servicelayer", autologon=True)
```

## Select a database

All the sample scripts use the *MI Training* database.

```python theme={null}
my_db = mi.get_db(db_key="MI_Training")
```

Set a unit system, and choose whether to use absolute or relative temperatures (Kelvin/Rankine or Celsius/Fahrenheit).

```python theme={null}
my_db.unit_system = 'UK Imperial'
my_db.absolute_temperatures = False
```

## Select a table

Select *MaterialUniverse* and print its number of attributes.

```python theme={null}
my_table = my_db.get_table("MaterialUniverse")
print("Table {0} has {1} attributes defined".format(my_table.name, len(my_table.attributes)))
```

*Previous cell output:*

```output theme={null}
Table MaterialUniverse has 424 attributes defined
```

Print the definition of an attribute within your table.

```python theme={null}
print("The definition of the Density attribute in {0} is {1}".format(my_table.name, my_table.attributes["Density"]))
```

*Previous cell output:*

```output theme={null}
The definition of the Density attribute in MaterialUniverse is <Attribute Definition, name: Density, type: RNGE, unit: lb/in^3>
```

## Find a record

Search for a record by name (only exact matches for short or long name will be returned), and print information to help you locate and view it in MI applications.

```python theme={null}
print("Finding Aluminum, 7075, wrought, T73...")
my_record = my_table.search_for_records_by_name("Aluminum, 7075, wrought, T73")[0]
```

*Previous cell output:*

```output theme={null}
Finding Aluminum, 7075, wrought, T73...
```

```python theme={null}
print("Found this record:")
my_record
```

*Previous cell output:*

```output theme={null}
Found this record:
```

*Previous cell output:*

```output theme={null}
<Record long name: Aluminum, 7075, wrought, T73>
```

```python theme={null}
print("in database/table:")
my_record.db_key+"/"+my_record.table_name
```

*Previous cell output:*

```output theme={null}
in database/table:
```

*Previous cell output:*

```output theme={null}
'MI_Training/MaterialUniverse'
```

```python theme={null}
print("at this point in the tree:")
"=>".join(my_record.path)
```

*Previous cell output:*

```output theme={null}
at this point in the tree:
```

*Previous cell output:*

```output theme={null}
'Metals and alloys=>Non-ferrous=>Aluminum=>Wrought=>7000 series (Zn-alloyed)=>7075'
```

```python theme={null}
print("with data like this:")
my_table.bulk_fetch([my_record], attributes=['Mg (magnesium)'])
my_record.attributes['Mg (magnesium)']
```

*Previous cell output:*

```output theme={null}
with data like this:
```

*Previous cell output:*

```output theme={null}
<RangeValue name: Mg (magnesium), value: {'low': 2.5, 'high': 2.5}, high_value_is_inclusive: True, low_value_is_inclusive: True, unit: %>
```

```python theme={null}
print("and you can see it in MI Viewer here:")
my_record.viewer_url
```

*Previous cell output:*

```output theme={null}
and you can see it in MI Viewer here:
```

*Previous cell output:*

```output theme={null}
'http://my.server.name/mi/datasheet.aspx?dbKey=MI_Training&recordHistoryGuid=7682acfe-46ca-4adf-94f7-6fa678debed1'
```
