Skip to main content
Add File, Picture, and Hyperlink attribute types to MI.

Connect to MI

Specify a database and table.

Create a new record

Define a path in the table from a starting folder (in this case the top level folder) using path_from(). If the path does not exist, the required folders will be created. Create a new Record object at the end of the path.
Previous cell output:
Access the empty AttributeFile, AttributePicture, and AttributeHyperlink objects.
Previous cell output:

Add files to the record

To add a file to a file attribute (or a picture to a picture attribute) there are two approaches. Create a File or Picture object, and set the binary_data property directly with either a file buffer or bytes object. (Useful when you have a file already loaded in your script.)
Previous cell output:
Use the AttributePicture.load() method to load a file from disk with a provided file name. (Useful when you have a file saved to disk).
Previous cell output:
To add a hyperlink to a hyperlink attribute, set the value property. Optionally, you can also set the hyperlink_display and/or hyperlink_description properties.
Previous cell output:
Set the new attributes to update, and write the changes to MI. Specifying include_binary_data_in_refresh = True means that the picture data will be included in the resulting Record object, rather than a URL reference to the picture data.

Save files attached to a record

Verify your changes by first extracting the new image from the record, then saving it to disk. You can either access the value directly or provide a file path to the save() method. First, ensure the output directory exists. This directory will already exist if a notebook was run previously that saved a file to disk.
Next, save the picture to disk.
jpeg