Get Attributes¶
Find out about the database schema by accessing the attributes property of the Table object.
Connect to MI¶
[1]:
from GRANTA_MIScriptingToolkit import granta as mpy
mi = mpy.connect('http://localhost/mi_servicelayer', autologon=True)
Get table¶
Get a database, then set the unit system for the Database object.
[2]:
db = mi.get_db(db_key='MI_Training')
db.set_unit_system('Metric')
db.unit_system
[2]:
'Metric'
Get a table from the database.
[3]:
tab = db.get_table('Training Exercise for Import')
tab
[3]:
<Table name: Training Exercise for Import, subsets: set()>
Access the attribute definitions¶
These are associated with the Table object through the attributes property, which returns a dictionary of AttributeDefinition objects.
[4]:
print('{:30.30} - {:^10.10} - {:^10.10} - {:^10.10}'.format('Name', 'Type', 'Unit', 'Meta?'))
print('-'*70)
for name, att in tab.attributes.items():
output = '{:30.30} - {:^10.10} - {:^10.10} - {:^10.10}'.format(name, att.type, att.unit, str(att.is_meta))
print(output)
Name - Type - Unit - Meta?
----------------------------------------------------------------------
Base - DISC - - False
Composition - STXT - - False
Density - POIN - kg/m^3 - False
Description - LTXT - - False
Document - FILE - - False
Electrical Properties - DISC - - False
Material - STXT - - False
More Information - HLNK - - False
Tensile Modulus - RNGE - GPa - False
Tensile Strength - RNGE - MPa - False
Transparent - LOGI - - False
Typical Use - PICT - - False
Young's Modulus - FUNC - GPa - False
Stress-strain Chart - FUNC - MPa - False
Creep Rupture - FUNC - MPa - False
Environmental Resistance - DSFN - - False
Design Allowable Data - TABL - - False
Atomic number - INPT - - False
Date of datasheet release - DTTM - - False
Wikipedia page - HLNK - - False
Environmental performances ove - TABL - - False
Characterization of this mater - TABL - - False
Yield Strength - POIN - MPa - False
[ ]: