Skip to main content

Connection Utils

This article explores the functionalities provided by the synutils.connection module in the Syntasa application. Connection utils provide a way to interact with connection parameters within the Syntasa application. It allows you to retrieve specific values associated with a connection using Python code. 1. getConnectionParam()

The getConnectionParam function is used to get the value of a specific parameter associated with a connection.

Parameters:

  • @inputConnection (String): This is the name of the connection you want to retrieve the parameter from.
  • param (String): This is the name of the specific parameter you want to retrieve the value for.

Return Value:

  • The function returns the value of the specified parameter as a string.

Example:

Python

/**  
*
* @param @inputConnection is a user parameter
* @param user parameter Name
* @return parameter Value
*/
getConnectionParam(@inputConnection: String, param: String)

Example :
paramVal = getConnectionParam("myConnection", "password")
print(str(paramVal))

Explanation:

  1. We define a variable paramVal and call the getConnectionParam function.
  2. The first argument passed to the function is the name of the connection, which is "myConnection" in this case.
  3. The second argument is the name of the specific parameter we want to retrieve, which is "password" here.
  4. The function retrieves the value of the "password" parameter from the "myConnection" and assigns it to the paramVal variable.
  5. Finally, we print the value stored in the paramVal variable using the print function.

Scala

/**  
*
* @param inputConnection is a user parameter
* @param user parameter Name
* @return parameter Value
*/

getConnectionParam(inputConnection: String, param: String)

Example :

val paramVal = getConnectionParam("@inputConnection1","password")

2. getConnectionParam()

The getConnection function, also part of the synutils.connection module is used to retrieve an entire connection object by its name.

Parameters:

  • connectionName (String): This is the name of the connection you want to retrieve.

Return Value:

  • The function returns the connection object as a Python object.

Example:

Python

/**  
* @param connectionName
* @return connection
*/

synutils.connection().getConnection(connectionName)
e.g
baseconnection = synutils.connection().getConnection("@InputConnection1")
print("connection : "+str(baseconnection))

Explanation:

  1. We import the getConnection function from the synutils.connection module.
  2. We define a variable baseconnection and call the getConnection function.
  3. The argument passed to the function is the name of the connection, which is "@InputConnection1" here.
  4. The function retrieves the connection object with the specified name and assigns it to the baseconnection variable.
  5. We attempt to print the connection object using print. However, it's important to note that for security reasons, printing the connection object might not reveal the actual connection details.

Scala

/**  
* @param connectionName
* @return connection
*/

synutils.connection().getConnection(connectionName)

Example:
baseconnection = synutils.connection().getConnection("@InputConnection1")
print("connection : "+ str(baseconnection))