MySQL Shell 8.0

10.2.2 Creating Extension Objects

To create a new extension object to provide one or more functions, data types, or further extension objects, use the built-in shell.createExtensionObject() function in JavaScript or shell.create_extension_object() in Python:


To add members to the extension object, use the built-in shell.addExtensionObjectMember() function in JavaScript or shell.add_extension_object_member() in Python:

shell.addExtensionObjectMember(object, name, member[, definition])


An extension object is considered to be under construction until it has been registered as a MySQL Shell global object, or added as a member to another extension object that is registered as a MySQL Shell global object. An error is returned if you attempt to use an extension object in MySQL Shell when it has not yet been registered.

Cross Language Considerations

An extension object can contain a mix of members defined in Python and members defined in JavaScript. MySQL Shell manages the transfer of data from one language to the other as parameters and return values. Table 10.1, “Supported data type pairs for extension objects” shows the data types that MySQL Shell supports when transferring data between languages, and the pairs that are used as representations of each other:

Table 10.1 Supported data type pairs for extension objects

JavaScript Python
Boolean Boolean
String String
Integer Long
Number Float
Null None
Array List
Map Dictionary

An extension object is literally the same object in both languages.