Browse Granta MI¶
Use various methods to get records from Granta MI.
This notebook shows three methods of browsing for records in Granta MI:
Get records by internal Granta MI identifier
Get records by an exact match on a short text attribute value
Get records by navigating the tree structure
Connect to MI¶
[1]:
from GRANTA_MIScriptingToolkit import granta as mpy
mi = mpy.connect('http://localhost/mi_servicelayer', autologon=True)
db = mi.get_db(db_key='MI_Training')
Access a record by specifying an internal ID¶
Get a record with a specific identifier, for example history GUID or history identity.
[2]:
record_by_guid = db.get_record_by_id(hguid='bf5e6054-6cad-4c9d-ad7a-adfa124c504b')
record_by_guid
[2]:
<Record long name:Soda barium glass>
[3]:
record_by_identity = db.get_record_by_id(identity=8925)
record_by_identity
[3]:
<Record long name:Alumino silicate - 1720>
Access a record by specifying a unique short text value¶
Get a record with a unique short-text attribute value using the Table.get_record_by_lookup_value() method.
[4]:
tensile_test_data = db.get_table('Tensile Test Data')
record_by_value = tensile_test_data.get_record_by_lookup_value('Specimen ID', 'MTS-615722')
record_by_value
[4]:
<Record long name:MTS-615722>
Note: This method can only return a single record; if multiple records have the same value an exception is raised. Uncomment the line below to see the error.
[5]:
# tensile_test_data.get_record_by_lookup_value('Testing Standards', 'ASTM E8')