19.5 Create Connections

Connections capture information on the systems where data is stored. The connections could be databases, cloud storage, applications, or services from where data is extracted or loaded.

This example illustrates a script that creates two Oracle connections in Data Transforms:

from datatransforms.workbench import DataTransformsWorkbench,WorkbenchConfig
from datatransforms.connection import Connection
from datatransforms.connection_types import  ConnectionTypes, ConnectionTypeDrivers

pswd="<your deployment pswd from secret store>"
connect_params = WorkbenchConfig.get_workbench_config(pswd)
workbench = DataTransformsWorkbench()
workbench.connect_workbench(connect_params)

src_connection = Connection()\
    .connection_name("Demo Source Data")\
    .of_type(ConnectionTypes.ORACLE)\
    .with_credentials("admin",Connection.encode_pwd("password goes here"))\
    .using_driver(ConnectionTypeDrivers.ORACLE)\
    .usingWallet("/path/of/the/source_dbwallet_file.zip")\
    .property("serviceName","your_adw_service")

workbench.save_connection(src_connection)


dw_connection = Connection()\
    .connection_name("Demo Target Data")\
    .of_type(ConnectionTypes.ORACLE)\
    .with_credentials("admin",Connection.encode_pwd("password goes here"))\
    .using_driver(ConnectionTypeDrivers.ORACLE)\
    .usingWallet("/path/of/the/targt_dbwallet_file.zip")\
    .property("serviceName","datatransformsdemos_high")

workbench.save_connection(dw_connection)

WARNING:

Never check-in or manage the production code with plain text passwords.

Testing connectivity

To test the connection, use test_connection method from Workbench. Returns True if the connection could be established.

#Assuming workbench is connected already...
test_connection = Connection().connection_name("connection-name")
connection_status = workbench.test_connection(test_connection)
logging.debug("Test connection is %s" , connection_status)