Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

Not applicable

CONNECTs other than LIB CONNECT are not available in this script mode

Hi,

I am trying to dynamically load ODBC Connection string through xml file (custom config file ) in  Qlik Sense Desktop 1.1  as below:

LET vFolderPath = 'lib://ReportsFilePath/';

LOAD key, value
FROM $(vFolderPath)AppConfig.xml (XmlSimple, Table is [qsConfiguration/qsElement])
WHERE key = 'ConnString';

LET vConnString = peek('value');

ODBC Connect to $(vConnString);

However, I receive following error on last line as:

CONNECTs other than LIB CONNECT are not available in this script mode.

Can you please help?

Thanks,

Greeshma

7 Replies

Re: CONNECTs other than LIB CONNECT are not available in this script mode

You have to define your ODBC connections first. Click on the Add Connection button in the Data Load Editor and choose ODBC from the standard connectors. Fill in the Create new connection (ODBC) form and save it. Then you can use this kind of connect statement:

LIB CONNECT TO 'AdventureWorksDW2014_ODBC';


talk is cheap, supply exceeds demand
Not applicable

Re: CONNECTs other than LIB CONNECT are not available in this script mode

I instead wish to load connection string from a config file. In my example above,

vConnString= " Provider=****;User Id=****; Password=****;Persist Security Info=****;Data Source=**** "

I am able to successfully connect using ODBC Connections defined under Data Connections. However, my intention is to load connection strings dynamically so that it could be run for different environment without any modifications to the data model script.

Re: CONNECTs other than LIB CONNECT are not available in this script mode

I think you'll have to create connections for each environment and choose the one you need. Maybe something like:

LET vEnv = 'Test'; //Choose from Dev, Test, Uat, Prod


LIB CONNECT 'MyODBC_DB_$(vEnv)' ;


talk is cheap, supply exceeds demand
Not applicable

Re: CONNECTs other than LIB CONNECT are not available in this script mode

Yup. That's one solution. That's how I am doing it now.  However, that hides connection information at run time.

Is there any specific file I can look at to see how connection is defined within Data Connections? Please let me know.

Thanks.

Re: CONNECTs other than LIB CONNECT are not available in this script mode

You could also use the same variable to load a file with connection information into another variable (or a table) for display in the front end.

My guess is that the data connection definitions will be stored in the qvf file.


talk is cheap, supply exceeds demand
Employee
Employee

Re: CONNECTs other than LIB CONNECT are not available in this script mode

Couple things:

You can actually run the load editor in legacy mode which will forego using the data connections that you define. In legacy mode the entire script runs as it would in QlikView. I'm not sure i recommend this but its possible.

When you import the QVF app into Qlik Sense server, unless there are connections of the same name already on the server, the server will add them into the QMC.  You can edit the connection from the QMC and see the full connect string.  I don't believe you can use variables here however. I tried some testing (set a variable in the load editor) and reference the variable in the connect string of the data connection used in the load script... but was not successful.

ikomlyakov1929
New Contributor III

Re: CONNECTs other than LIB CONNECT are not available in this script mode

But you can make your Server to load data in legacy mode too but you won't be able to manage the connection strings in QMC anymore.

Community Browser