Loading custom connections

You can instantiate a local connection for testing, using the name of your custom connection directory, a sample connection name, and an optional dictionary of parameters. This local connection object can then be used to test and implement functions in your custom connection.

The following code sample loads custom connection package directories in the same way that the CML Data Library imports a registered custom connection when called with get_connection:

get_custom_connection_from_local(package_name, connection_name, parameters={})

Returns a CML Custom Data Connection object. For testing in-development Data Connection code.


  • package_name (str): The accessible package name containing custom connection code to load.
  • connection_name (str): The connection name to be used in Custom Connection loading.
  • parameters (dict of str: str): Mapping of custom parameter keys and values that will be loaded by the custom connection code.


A custom connection object that implements cml.data_v1.customconnection.CustomConnection

Usage: conn = load_custom_connection_source("myconndir", {"HOSTNAME": "my.instance.host.com"})

Note: When you make changes to your custom connection file, get_custom_connection_from_local will dynamically re-import the contents, so the latest code on disk is instantiated for the local connection.

To load any created data connection that is available in the CML project, use the get_connection instruction.

get_connection(dataconnection_name, parameters=None)

Usage: conn = get_connection(connection_name)

If the specified connection is of type “Custom” a snapshot of the Custom Data Connection files specified at the time of Connection creation is imported.