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:
- We define a variable
paramVal
and call thegetConnectionParam
function. - The first argument passed to the function is the name of the connection, which is "myConnection" in this case.
- The second argument is the name of the specific parameter we want to retrieve, which is "password" here.
- The function retrieves the value of the "password" parameter from the "myConnection" and assigns it to the
paramVal
variable. - Finally, we print the value stored in the
paramVal
variable using theprint
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:
- We import the
getConnection
function from thesynutils.connection
module. - We define a variable
baseconnection
and call thegetConnection
function. - The argument passed to the function is the name of the connection, which is "@InputConnection1" here.
- The function retrieves the connection object with the specified name and assigns it to the
baseconnection
variable. - 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))