Developing and testing your first custom connection

You can develop a custom connection in your own project, as shown in this example.

  1. Create a new directory hello-world-conn-dev and file to contain your custom data connection files.
  2. Implement your custom data connection in (There must only be one class which implements CustomConnection in this directory.)
    """Hello World Custom Connection Implementation"""
    from cml.data_v1.customconnection import CustomConnection
    class HelloWorld(CustomConnection):
        """ Implementation of the interface function print_usage"""
        def print_usage(self):
            print(""" This is a %s connection"""% (self.app_name))
        """ Implementation of custom function for hello connections"""
        def hello_world(self):
            print("These are the specified parameters" )
            print (self.parameters)
  3. Test your custom data connection locally (for more information see Loading custom connections)
    test_params = {"PARAM_1": "foo", "PARAM_2": "bar"}
    import cml.data_v1 as cmldata
    conn = cmldata.get_custom_connection_from_local(
  4. In Site Administration > Data Connections, select New Connection, and fill in the fields as shown below.
  5. See Data connection management to set the availability of your newly created custom connection in new and existing CML projects.
  6. Create a project, and start a session to use your completed Hello World connection!
    Note: A default custom connection code snippet is automatically displayed to the user.